💬 Easy/Newbie PCB for MySensors
-
Hi,
First of all, thank you @sundberg84 for this great PCB. Super easy to work with. Still; there is one question that I haven't been able to figure out yet.
I'm running my pcb as a battery node and want to monitor the battery status. However A0 always returns a value somewhere around 30 +/- 15 - even with brand new batteries. Calculated into voltage, this would mean around 1,04V.
I've checked and double checked that I'm using 470k and 1M resistors.
I've also measured using a multi meter, with incoming value of 3,2 V and outgoing from booster 3,36V.Any ideas that might point me in the right direction for solving this noob issue?
-
Hi,
First of all, thank you @sundberg84 for this great PCB. Super easy to work with. Still; there is one question that I haven't been able to figure out yet.
I'm running my pcb as a battery node and want to monitor the battery status. However A0 always returns a value somewhere around 30 +/- 15 - even with brand new batteries. Calculated into voltage, this would mean around 1,04V.
I've checked and double checked that I'm using 470k and 1M resistors.
I've also measured using a multi meter, with incoming value of 3,2 V and outgoing from booster 3,36V.Any ideas that might point me in the right direction for solving this noob issue?
@daand83 - do you mean analogread() always returns 30 but you still got 1,04V in? If so, either you have a bad connection to A0 or the chip is broken. I have had atmegas (pro mini) which was broken.
You could try soldering a second wire from A0 to the voltage divider to exclude connections errors. You could also measure the voltage input on the atmega chip. If its 1.04 there as well a bad connection can be excluded and you hav a bad pro mini / atmenga chip.
It coule be a code error as well, if you have changed to code...
-
@daand83 - do you mean analogread() always returns 30 but you still got 1,04V in? If so, either you have a bad connection to A0 or the chip is broken. I have had atmegas (pro mini) which was broken.
You could try soldering a second wire from A0 to the voltage divider to exclude connections errors. You could also measure the voltage input on the atmega chip. If its 1.04 there as well a bad connection can be excluded and you hav a bad pro mini / atmenga chip.
It coule be a code error as well, if you have changed to code...
@sundberg84
Hi,What I've done is this;
Measured voltage on PWR/GND which returns 3,2 V. I've measured voltage on GND/Vout on the battery booster which returns 3,36V. However, analogread always returns something like 300 +/-10, which (using the formula provided) indicates a voltage of 1,04 V and a battery percentage of ~30%. This has been the case with brand new batteries as well as old ones... -
@sundberg84
Hi,What I've done is this;
Measured voltage on PWR/GND which returns 3,2 V. I've measured voltage on GND/Vout on the battery booster which returns 3,36V. However, analogread always returns something like 300 +/-10, which (using the formula provided) indicates a voltage of 1,04 V and a battery percentage of ~30%. This has been the case with brand new batteries as well as old ones...@daand83 - this is quite dependent on which code you use I think but it sounds right. A return of 1000 would be 3,3V in my code.
This is my code:
Defines:
//========================= // BATTERY VOLTAGE DIVIDER SETUP // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 #define VBAT_PER_BITS 0.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564) #define VMAX 3.0 // Vmax = (2xAA bat)=3.0V (892) int batteryPcnt = 0; // Calc value for battery % int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //=========================Setup()
analogReference(INTERNAL); // For battery sensingLoop()
delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print(batteryPcnt); Serial.println(" %"); gw.sendBatteryLevel(batteryPcnt);I think you should measure the voltage on A0 to Gnd and see what you get.
-
@daand83 - this is quite dependent on which code you use I think but it sounds right. A return of 1000 would be 3,3V in my code.
This is my code:
Defines:
//========================= // BATTERY VOLTAGE DIVIDER SETUP // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 #define VBAT_PER_BITS 0.003363075 #define VMIN 1.9 // Vmin (radio Min Volt)=1.9V (564) #define VMAX 3.0 // Vmax = (2xAA bat)=3.0V (892) int batteryPcnt = 0; // Calc value for battery % int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point //=========================Setup()
analogReference(INTERNAL); // For battery sensingLoop()
delay(500); // Battery monitoring reading int sensorValue = analogRead(BATTERY_SENSE_PIN); delay(500); // Calculate the battery in % float Vbat = sensorValue * VBAT_PER_BITS; int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (batteryPcnt > 100) { batteryPcnt=100; } Serial.print(batteryPcnt); Serial.println(" %"); gw.sendBatteryLevel(batteryPcnt);I think you should measure the voltage on A0 to Gnd and see what you get.
@sundberg84 - the only weird part is that analogread() returns a value of 300, which in turn is below VMIN; and hence a negative value (1,04-1,9)/(3,0-1,9) = -78%.
But if I understand you correctly the next two steps in the troubleshooting process would be;
- measure GND/VCC on the atmega-chip as well to make sure that it is indeed not a faulty chip?
- solder a second connection from A0 to the voltage divider to remove any bad connections
Thanks again :) :+1:
-
@sundberg84 - the only weird part is that analogread() returns a value of 300, which in turn is below VMIN; and hence a negative value (1,04-1,9)/(3,0-1,9) = -78%.
But if I understand you correctly the next two steps in the troubleshooting process would be;
- measure GND/VCC on the atmega-chip as well to make sure that it is indeed not a faulty chip?
- solder a second connection from A0 to the voltage divider to remove any bad connections
Thanks again :) :+1:
I have to verify when I get home, but I've probably found the problem... Seems as a stupid copy/paste problem. No call to analogreference(INTERNAL). Don't know how I've been able to overlook this for a week now, but... Will check back with result later on...
-
I have to verify when I get home, but I've probably found the problem... Seems as a stupid copy/paste problem. No call to analogreference(INTERNAL). Don't know how I've been able to overlook this for a week now, but... Will check back with result later on...
@daand83 - haha, easy to forget - I also forgot to post in in my example above (changed now) :)
Only one line of code in a different place... well, hope you found it! -
@daand83 - haha, easy to forget - I also forgot to post in in my example above (changed now) :)
Only one line of code in a different place... well, hope you found it!@sundberg84 - Indeed missing analogreference. All good now, even got a battery value of 102 % ;)
-
@sundberg84 said:
AMS1117
mmmm I would like to see a board with room for AMS1117 and caps... :)
While waiting for my Newbie PCBs to arrive I have built my own test sensor on a bit of breadboard. Got the new 0,8-3.3v to 3.3v today. My boosters. So, I just cut the trace going from the battery to the rest of the components and arduino and there I connected my booster. VIN directly from bat + and gnd from bat -, Also, everything else that need GND is connected to the same place. I then reconnected the plus power rail to the power coming from the booster. I also moved the radio connection so that if feed directly from the battery. Measurements show me 3.3 v to arduino and other sensors and about 2.9 to the radio directly from batt. Something does not want to work. It is something with the power to the radio. Running sensor on battery only, no booster, works just fine. Running node with everything on vout from the booster, it just won't work. The radio struggles to do something useful but it fails. Running radio on batt and the rest on booster does not work. 'But, if I power the node with power from the serial adapter. the node woks again but only if the battery provide power to the radio at the same time.
Any suggestions? Quite tired, can be messy ;)
-
@sundberg84 said:
AMS1117
mmmm I would like to see a board with room for AMS1117 and caps... :)
While waiting for my Newbie PCBs to arrive I have built my own test sensor on a bit of breadboard. Got the new 0,8-3.3v to 3.3v today. My boosters. So, I just cut the trace going from the battery to the rest of the components and arduino and there I connected my booster. VIN directly from bat + and gnd from bat -, Also, everything else that need GND is connected to the same place. I then reconnected the plus power rail to the power coming from the booster. I also moved the radio connection so that if feed directly from the battery. Measurements show me 3.3 v to arduino and other sensors and about 2.9 to the radio directly from batt. Something does not want to work. It is something with the power to the radio. Running sensor on battery only, no booster, works just fine. Running node with everything on vout from the booster, it just won't work. The radio struggles to do something useful but it fails. Running radio on batt and the rest on booster does not work. 'But, if I power the node with power from the serial adapter. the node woks again but only if the battery provide power to the radio at the same time.
Any suggestions? Quite tired, can be messy ;)
@NiklasO - do you have any serial log?
2,9V should be just fine for the radio, but it might freeze with spikes from booster or other power circuit. A 0,1cap from Out to Gnd on the booster might help.Try to remove the booster and verify if the radio works then - if so, its the booster. If not try another radio - we know the radios is very different quality sometimes.
-
Hello, I think @sundberg84 is right, you need some capacitors to filter the noise from the booster, the best is to put the same than those that are on EasyPCB (top of the voltage regulator).
Even if you power the radio directly from the battery, the booster will generate some noise if you use it to power the board, as they have the same GND. -
@NiklasO - do you have any serial log?
2,9V should be just fine for the radio, but it might freeze with spikes from booster or other power circuit. A 0,1cap from Out to Gnd on the booster might help.Try to remove the booster and verify if the radio works then - if so, its the booster. If not try another radio - we know the radios is very different quality sometimes.
@sundberg84 said:
@NiklasO - do you have any serial log?
2,9V should be just fine for the radio, but it might freeze with spikes from booster or other power circuit. A 0,1cap from Out to Gnd on the booster might help.Try to remove the booster and verify if the radio works then - if so, its the booster. If not try another radio - we know the radios is very different quality sometimes.
Thanks for the answers guys!
Everything works as it should when all on battery.
Out to GND already have a cap. The same one the radio use? If it sits between radio vcc and gnd-pin that would be the same as between Vout and GND on the booster, right? I have tried with caps at 0,1 - 100uF. The current one is at 47uF. The serial log say stuff about signing error and other like !TSM:UPL:FAIL when radio on battery and the rest on booster Vout. Reports radio OK at start. All has the same GND.
The multi meter show a quite stable 3.3v output from the booster but I don't have any oscilloscope to see the eventual noise. I have tried different boosters but all are probably the same batch, marked "Canton-power" I think. Also, the radio seem to freeze the Gateway. My sensor tries to communicate with the gateway (I have green, yellow, and red leds connected to both gw and my testsensor). On the sensor the yellow and green blink momentarily and then it greets me with angry red led blinking at me. ;) The gateway does the same ofc but often it freezes with all the three leds constantly on. To make the gateway accept connections again I have to reset it but this does only happen with this troublesome sensor with radio on bat, rest on booster. Other than that the gateway works great with my other sensors (all on battery only for now). -
You have to combine different capacitor values to have some efficient filtering.
If you respect what is implemented on EasyPCB board you should have :- 0.1µF and 10µF as close as possible to the booster output
- your 47µF as close as possible to the GND/VCC of the radio
Location of capacitors is important as if they are far from the radio for example, the wires to the radio act as antenna and will catch noise generated by the booster. So in addition to the capacitors at the right position, try to have wires going to the radio as short as possible.
-
You have to combine different capacitor values to have some efficient filtering.
If you respect what is implemented on EasyPCB board you should have :- 0.1µF and 10µF as close as possible to the booster output
- your 47µF as close as possible to the GND/VCC of the radio
Location of capacitors is important as if they are far from the radio for example, the wires to the radio act as antenna and will catch noise generated by the booster. So in addition to the capacitors at the right position, try to have wires going to the radio as short as possible.
-
Just wanted to say that my first sensor on this board works great! Measuring passives in place. Worked first try.
On battery, with booster and one DS18B20 temperature sensor.Great work @sundberg84!
-
@sundberg84: I have plan to use your pcb to build ethernet gateway, thus I want to use NRF24L01+ radio with external antenna. In this case it's more than recommended to use external power to supply the radio as pro mini has not enough juice to feed radio properly. Could you please give me some hint how to do it in most elegant way? I think it should be enough to do not solder radio's vcc and gnd pins to pcb, but to connect external power supply to these pins with hardsoldered capacitor. What do you think?
-
@sundberg84: I have plan to use your pcb to build ethernet gateway, thus I want to use NRF24L01+ radio with external antenna. In this case it's more than recommended to use external power to supply the radio as pro mini has not enough juice to feed radio properly. Could you please give me some hint how to do it in most elegant way? I think it should be enough to do not solder radio's vcc and gnd pins to pcb, but to connect external power supply to these pins with hardsoldered capacitor. What do you think?
@fisher - that is exactly what I did... i made a external "powerpcb" which i could connect the radio to and the node (Arduino + Ethern module) to. This way I didnt feed the radio from the arduino. Be sure to use a voltage regulator with a good ampere output.
Check this: https://www.openhardware.io/view/207/Mysensors-20-ethernet-gateway-W5100-build
-
@sundberg84: thx for the quick response. I saw your post with external ethernet gateway but I'd like to avoid use of jumper wires and use your newbie psb instead
-
@sundberg84: thx for the quick response. I saw your post with external ethernet gateway but I'd like to avoid use of jumper wires and use your newbie psb instead
@fisher - well, the only option then is to use a 3.3v arduino on my PCB and BAT jumper. Then make sure you have a steady 3.3v on PWR on the PCB. If you have any units (like ethernet module?) that needs 5v you need a step up for this... i guess there are many ways to solve this but I have not tried them so you need to experiment a little.
