Tapatalk

Anomalies when powering from 2xAAA

Anomalies when powering from 2xAAA

3

PostJun 05, 2020#1

When powering from USB (5v) my sketch runs as expected, when powering from 2xAAA via battery pack accessory I get a few weird behaviours.

Output on USB ~5V:
5v_normal.png (39.63KiB)

Output on battery:
battery_abnormal2.png (39.12KiB)

The Serial output is disjoined, text will be randomly cut off, you can see that in the final output in the picture above.
The text still appears to be in a buffer as when the device wakes up for next poll the remaining text will appear in the next output (as is evident by all the proceeding outputs being complete).

The temperature sensor (DS18B20) reports -127.0 degrees on most readings (sometimes it reports a reading, but mostly it's -127), I'm assuming this is its null value.

I added a whole bunch of delay() statements to my code, to give it enough time to output prior to sleeping, and also added Serial.flush() to attempt to get it to flush all the output prior to sleeping.
This was mostly to try and solve the Serial output issue.

I have no idea how to solve the DS18B20 issue, I'm getting a steady 3.26v on the 3.3v headers so I'm not sure why it would be returning a null value.

Here is my code, it's fairly simple, inclusive of all the additional delay() statements.

Code: Select all

#include "struct.h"
#include <T2WhisperNode.h>
#include <LowPower.h>
#include <RH_RF95.h>
RH_RF95 myRadio;

T2Flash myFlash;

#define RADIO_FREQUENCY 868.0
#define RADIO_TX_POWER 13
#define SERIAL_BAUDRATE 115200

#include <OneWire.h>           // DS18B20 Libraries
#include <DallasTemperature.h> // DS18B20 Libraries
#define ONE_WIRE_BUS 3         // DS18B20 GPIO
OneWire oneWire(ONE_WIRE_BUS);       // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature ds18b20(&oneWire); // Pass our oneWire reference to Dallas Temperature sensor

void read_ds18b20(SENSORDATA* data) {
  ds18b20.requestTemperatures();
  data->ds18b20.temperature = ds18b20.getTempCByIndex(0);
}

#include "DHT.h"
#define DHTPIN 8
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

void read_dht(SENSORDATA* data) {
  data->dht.humidity = dht.readHumidity();
  data->dht.temperature = dht.readTemperature();
  
  if (isnan(data->dht.humidity) || isnan(data->dht.temperature)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  data->dht.heatindex = dht.computeHeatIndex(data->dht.temperature, data->dht.humidity, false);
}

void setup() {
  Serial.begin(SERIAL_BAUDRATE);
  while (!Serial) {} // Wait for Serial

  // Radio - Initialize the radio and put it to sleep to save energy
  myRadio.init();
  myRadio.setFrequency(RADIO_FREQUENCY);
  myRadio.setTxPower(RADIO_TX_POWER);
  myRadio.sleep();

  // Flash - We're not using, so just power it down to save energy
  myFlash.init(T2_WPN_FLASH_SPI_CS);
  myFlash.powerDown();
  
  dht.begin();
  ds18b20.begin();
  delay(1000);
}

void loop() {
  delay(1000);
  SENSORDATA data;
  delay(1000);
  read_dht(&data);
  delay(1000);
  read_ds18b20(&data);
  delay(1000);
  data.power.battery = T2Utils::readVoltage(T2_WPN_VBAT_VOLTAGE, T2_WPN_VBAT_CONTROL);
  delay(1000);
  data.power.supply = T2Utils::readVoltage(T2_WPN_VIN_VOLTAGE, T2_WPN_VIN_CONTROL);

  Serial.println(F("-------------------------"));
  Serial.print(F("   Temperature: ")); Serial.print(data.ds18b20.temperature); Serial.println(F("ºC  "));
  Serial.print(F("      Humidity: ")); Serial.print(data.dht.humidity); Serial.println(F("%"));
  Serial.print(F("       Battery: ")); Serial.print(data.power.battery); Serial.println(F(" millivolts."));
  Serial.print(F("  Power Supply: ")); Serial.print(data.power.supply); Serial.println(F(" millivolts."));
  Serial.flush();
  delay(1000);

  myRadio.send((uint8_t *) &data, sizeof(data));
  myRadio.waitPacketSent();
  myRadio.sleep();
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
}

PostJun 05, 2020#2

I also just tried another Whisper Node board and different DS18B20, same results

OK the DS18B20 works when on pin D8 (after I remove the DHT11 and comment out it's code).
The only time the DS18B20 works on D3 is when connected to USB 5V.

I thought I would be able to use D3. Any suggestions?

PostJun 06, 2020#3

The DS18B20 module from Jaycar, has 4.7K pull-up resistor between Vdd and Data, as expected, however it also has an LED in series to indicate activity. For some reason this works fine when the Whisper Node is powered from USB power, however doesn't when powered by battery pack. Removing this LED and bridging the point, leaving just the 4.7K pullup between Vdd and Data allows the sensor to work.

I'm curious to know why this would be a problem however, and why it would only occur when powered from battery, as the 3.3v outputs on the board should be voltage regulated. Any ideas?