Well just because we all know Dave Jones' opinion of "The Internet of Things", it is time to bring his uCurrent to the dark side! Just kidding, Dave if you are reading this, I just thought that it would be a fun project :)
I love my uCurrent and use it all of the time for measuring power consumption of small low power devices. I've been working on some solar stuff where I want to measure current over a long period & a wireless interface/data logging would be handy. There are some other instances where I just can't be bothered to get out (or find) my DMM, untangle the leads and get it all together. Not to mention my desk ALWAYS looks like this!
Anyway from my other updates You'll find that I've been working on a new low cost sensor node that supports BLE as well as the standard Nordic Enhanced Shockburst protocol. The size of this node is small so I figured it would be a perfect marriage to put them together. There are just 4 connections:
Here's the code, apologies in advance for the egregious use of floats, it is a hack after all...
#include <analog_io.h>
#include <SPI.h>
uint8_t x = 0;
analog_io radio(P3_5, P3_6, P2_5);
float ref, I;
float Current;
uint16_t batt,lp_ref;
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
void setup()
{
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
radio.begin(); // Defaults 1Mbps, channel 0, max TX power
radio.setTXaddress((void*)txaddr);
analogReference(INTERNAL2V5);
}
void loop()
{
lp_ref = analogRead(A0);
batt = analogRead(11)>>1;
if (lp_ref-batt>100) {
for (int k=1;k<=100;k++) {
ref -= ref/k;
ref += analogRead(A0)/k;
I -= I/k;
I += analogRead(A3)/k;
}
Current = (I-ref)*0.00244140625;
radio.print(Current,3);
radio.flush();
delay(250);
radio.print(Current,3);
radio.flushBle();
delay(250);
}
else {
sleep(5000);
}
}
By the way, you can find the analog_io library here. The Rx code is straight from the "proprietaryRfRx" example.All that is left is to put it back together:
Add some tape for good measureThere is one more thing to consider, I'm using the 2.5V reference in the MSP430. That means that I can't measure voltages greater than 2.5V from GND. The way that the uCurrent works is that in order to do bi-directional current measurements, it sets the virtual reference at VCC/2, about 1.5 V. So the measurement range is degraded to, -1.5mA to +1.0mA. Nothing quite works close to the rails either so be advised.
Since I don't really use the bi-directional aspect of my uCurrent, I'm tempted to lower the virtual ground to something like 200mV and get more range. I digress...
Feel free to comment, send a skull my way or follow the project! Sensor nodes are for sale too, send me a message it you would like to purchase. $15 for the node, an extra $5 if you want a Si7020 Temp & Humidity sensor soldered on. $5 Shipping world wide (except for a few countries).
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.