Saturday, December 20, 2014

Power Monitoring with the Moteino -- Attempt #2

This weekend at the Milwaukee Makerspace, I continued trying to get my Moteinos to communicate to each other.  I want to get a node to send its power level to the host.  I performed a number of tests and eventually accomplished the goal.

Basic TxRx Test
First, I numbered the Moteinos 1, 2, and 3.  Each Moteino was setup at a frequency of 915mhz.  The high power setting for the RFM69HW was set on all Moteinos.  For the first test, I opened the serial terminal window in the Arduino IDE on each Moteino so I could see the messages it was sending.  For the other tests, the terminal was only on the Receiver.

The test involved uploading the TxRxBlinky sketch on each Moteino -- one as the Receiver, and one as the Sender.  I hooked a button up to the Sender.  Once both Moteinos were powered up, I pushed the button on the Sender.  This caused the LED on the Receiver to change state -- on to off or off to on.  The Receiver also sends some text to the serial monitor.


All tests passed.  All Moteinos can both send and receive.  Also, they all operate with either the USB as a power source or the Lithium 6v battery as the power source.

Gateway / Node Test
For the next test, I used the Gateway / Node sketches from LowPowerLab.  The Gateway sketch was loaded on the Receiver Moteino and the Node sketch was loaded on the Sender Moteino.  All Moteinos were set at 915mhz frequency.  The high power setting was set on all Moteinos.

Before testing a pair of Moteinos, I loaded the Node sketch on one Moteino and watched what happened with the serial monitor.  The Moteino outputted exactly what it was supposed to.

Next, I uploaded the Gateway sketch to a Moteino and started testing.


All tests passed.

Custom Node Test
Now that I know all of Moteinos can talk to each other, I tested a custom node program.  It is set to transmit at 915mhz.  The high power setting for the RFM69HW is set.

The custom program is a modified version of the Node sketch from LowPowerLab.  The sketch reads the voltage from the Moteino and transmits it to the host.  (More information about the code to read the voltage is in this post.)

I had the same problem with the sketch that I had last week.  If the Node program tries to read the voltage using the readVCC function, then tries to use the radio.sendWithRetry function, the Moteino appears to reboot--it is re-running the setup function.  If I comment out the line that calls readVCC, the rest of the code processes normally.  However, the send line prints the message indicating it failed.  

After a lot of testing, I realized that the failure message I am getting is always there -- even with the code that comes with the Moteino.  I ran my Node program and the Host displayed the voltage from the Node.  The code works even though the failure message prints.  I don't know if there is something wrong with the code or if I don't understand how the read.send function is supposed to work.

I don't know why the Moteino was rebooting.  I did fix that problem by starting over with the original Node program and adding my code bit by bit.  The problem did not re-occur.  Maybe I had some invisible characters in the code.

Finally, I tested the voltage that is read by the node.  I connected a variable power supply to the power input on the Node.  This let me vary the input voltage.  I started at 6 volts and slowly turned the voltage down.  Sending any voltage over 3.2 registers as 3349 millivolts.  Once the voltage was turned down to 3.2 volts, the device read 3205 or 3196 millivolts.  When the input got down to 3.1 volts, the node stopped transmitting.  So, I will be able to use this code to monitor my battery's voltage.

One of the next steps is to understand how the node and host communicate.

  • Can the node sleep until the host calls it?  
  • If the node sends data to the host, will it get lost?  Is there a way to know for sure?
  • How do we make the device truly low-power?
  • What does the Ack do?
Another step is to connect the host to a Raspberry Pi and have the Pi read the serial inputs.

RPI serial console:


No comments:

Post a Comment