![]() |
Forum Index : Microcontroller and PC projects : Water Level meter - How to sleep mode
Page 1 of 3 ![]() ![]() |
|||||
Author | Message | ||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
I am putting together a project that will hopefully sense the water level in a water tank some 300 metres from my house and wireless-ly display that level value within the house. I have the following components: 2x Arduino nanos 2x HC-12 wireless JSN-SR04T ultrasonic sensor LMC-SSC2A16 lcd panel I have confirmed by prototyping, that all the components work as intended, including the wireless range beyond 300 m, and I am reasonably confident that I can cobble together the sub-components into a workable system. What I am not sure about is the method to use for putting the system to sleep for most of the time, so that battery supply at the tank becomes practical. So that would involve sleeping the following: HC-12 Ultrasonic Sensor Nano I think I follow the software method for shutting down the nano’s subsystems for a set time interval to achieve low average micro-amp drain. Since I need to also sleep and wake both the HC-12 and Ultrasonic Sensor I imagine that a Mosfet switch could be appropriate. I am not equipped to design a circuit for the Mosfet but given a suitable circuit diagram I could handle the assembly, even if it involved SMD components. Any help to point me in the right direction would be very welcomed. |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I would switch VDD for the HC-12 and Ultrasonic sensor (tie their VDD together) using a MOSFET - something like FQP30N06L. It is a TO220 package and 22A continuous across the drain/source(!) This is way more than you'll need but it is cheap and means it will provide a power feed to both devices without a heatsink - HC-12 can be juicy in high-power mode. Also, you can drive it's gate direct from a microcontroller pin. Initialise this pin as an output (lo) early in your code. I don't know anything about SLEEPing an arduino but the process flow would be simply, wake from SLEEP, send the gate control pin hi (to feed juice to your sensor and HC-12), pause for a couple of seconds to let them stabilise, do your sample (take a few and average them), transmit the result, pausing for a couple of seconds to let it get away, gate pin lo and SLEEP... repeat. When you get your HC-12's, buy them as a pair at the sme time. There was a thread here about a mis-matched crystal on some clones and although they were fine when used with their own kind, the mismatch meant they were incompatible with the genuine article With your ultasonic sensor, beware there seem to be two types, one samples on demand via the trigger input and the other free-runs putting out a serial stream with a direct reading in mm- they can be very difficult to identify check through this thread about half way down. hth h |
||||
ryanm Senior Member ![]() Joined: 25/09/2015 Location: AustraliaPosts: 203 |
Quiescent current draw on the nano Vreg is 5mA ( from memory). Even with the 328P and radio turned off you'll get a few weeks max of a reasonably sized lipo or a few AAs. |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
Thank you very much CaptainBoing for the heads up in my water level sensing project. I bought 4 of the HC-12 back in April 2018, right in the middle of the period when the suspect devices came to light. I’ll be using two of these so they should be matched. One day I might determine whether they are on or off spec. The ultrasonic sensors have passed muster so far in my testing. If I encounter problems down the track I’ll follow up on your advice on two varieties. |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
Thanks for you feedback ryanm. I concluded that I could get to tiny microamps in sleep mode for the Nano after viewing the following youtube video: https://www.youtube.com/watch?v=urLSDi7SD8M |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
For sleeping the HC12, you can use your Arduino, and connect the HC12 SET line to a spare I/O on the Arduino, and use that to command the module to sleep and wake. The other way is as CaptainBoing said - use a transistor switch. As the HC12 shares a common ground with the serial port and RF out, you need to use a high-side switch, or any other ground point will provide power to the HC12, and it could even operate on parasitic power via some resistors on the module to the 5v pin. Not enough to make the module actually work, but it could cause the module to misbehave(as it might have high-impedance power, but not enough current to actually do much, which can confuse the module). I used a P-MOSFET and an NPN 'Helper' transistor as a high-side switch to control the 5v to the HC12. This has been documented elsewhere on the forums, but if you can't find it, I can re-upload the schematic or you can ask Mr. Google for an image of "P-channel high-side switch". To save four components(two transistors and two resistors), I just use the SET line on the HC12 now, and command it to sleep via code. In sleep mode, the HC12 sucks about 22uA according to the datasheet. Smoke makes things work. When the smoke gets out, it stops! |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
Which MOSFET did you end up using Grogs? |
||||
ryanm Senior Member ![]() Joined: 25/09/2015 Location: AustraliaPosts: 203 |
Only watched the first few seconds of the video, so I might be wrong, but he was using a raw 328P chip (programmed with Arduino framework). Most official arduino boards have a linear voltage regulator like a LM1117? or similar which takes 7-12v and outputs regulated 5V. This regulator itself draws power even with no load attached (Quiescent Current). So even if you pry the micro off the board a 2000mah lipo would be dead in 400 hours or a bit over a fortnight which would get annoying pretty quick. Quick question, what's more important time or money? There's people on both sides on the forum, neither is worse than the other. You could desolder the chip and replace ( bit of fiddly work and $1) or use the nano on a mains project and get a low power board, $15-$30 maybe? |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
you could investigate a small solar panel as a top-up. Might be enough to keep the battery going, in the ever present Oz sunshine ![]() |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
Neither time nor money are the main drivers now. The incentive has become the challenge to solve the problem in an interesting if not elegant way. The Nano uses the AMS1117 regulator and as you so rightly point out this has a quiescent current of 5mA. When you say to maybe “desolder the chip” I assume you are referring to the 1117. That sounds like a good way to go for my purposes. I assume that the 1117 would only be needed if you are powering the Nano with 7 to 12 volts using the Vin pin or the power plug. Alternatively I suppose I could use the ATmega32 chip and the minimal support components as used in that video, instead of a Nano or Uno. (I could program it in a spare Uno that I have). |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
I did consider solar, but if most of the generated power is going into keeping the linear regulator warm rather than productive purposes then I am keen to pursue a low power solution and battery to see if that is possible. It is certainly a welcomed learning exercise for me too. In addition I think by avoiding solar I can make the system more physically robust. It seems that Grogster has identified a problem with an n-channel device and would go with a p-channel instead. I too would be interested in the actual MOSFET that he would recommend. |
||||
Grogster![]() Admin Group ![]() Joined: 31/12/2012 Location: New ZealandPosts: 9610 |
I used a DMP2305, which is SOT-23, and has an RDS of 90 milli-ohms at -2.5v Vdss of -20v, Vgss of +/-8v, I=-4.2A. I helped that along with an FMMT493 NPN transistor in SOT-23. When I did use this arrangement, I would switch the HC12 off and on when wanted. It worked fine, but using the SET line and commands in code saved me four parts. Technically in sleep, the HC12 still sucks about 22uA, but that is essentially nothing. The transistor method means the HC12 sucks no current at all when off, so if every single joule of battery energy is important, then the transistor method would still be a useful way to go. Smoke makes things work. When the smoke gets out, it stops! |
||||
ryanm Senior Member ![]() Joined: 25/09/2015 Location: AustraliaPosts: 203 |
Had a few suggestions, but they all run at 3.3V. Haven't managed to find a cheap sealed ultrasonic transducer that runs at 3.3V. Maxbotix ones do, but they're around $150. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
Hi, This is typically something I would do in a PICAXE. The PICAXE microcontrollers have a sh*tload of sleep and low power commands build in that actually work. The ultrasonic range finder can be implemented using pulseout and pulsein commands (search picaxe forum). Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
![]() Grogster, I found the above image on another thread and I guess it is the circuit you are referring to. You desribe it further in that thread with the following: "This was what I have been using up until now, but it requires four extra SMD parts. It is a high-side switch for just about anything with a common-ground. I used 1k for R7, 100k as the R6, the NPN I used was an FMMT493 in SOT-23 flavour, and the MOSFET I used was a DMP2305 also in SOT-23. " Many thanks for all your info. |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
This is typically something I would do in a PICAXE. The PICAXE microcontrollers have a sh*tload of sleep and low power commands build in that actually work. I've not had any contact with the PICAXE but I'll certainly look at it if I hit an impasse with Arduino. |
||||
ryanm Senior Member ![]() Joined: 25/09/2015 Location: AustraliaPosts: 203 |
I wouldn't be too concerned with what chip framework you go with. There are at least half a dozen common ones out there that could do the job no worries, just use what's familiar to you. Getting the micro to sleep is easy with freely available libraries. It's managing the ultrasonic and radio that will eat up your battery. |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
This is typically something I would do in a PICAXE. The PICAXE microcontrollers have a sh*tload of sleep and low power commands build in that actually work. I've not had any contact with the PICAXE but I'll certainly look at it if I hit an impasse with Arduino. Plus 1 for getting the picaxe to operate at very low power. 10 years and 10 months ago I built a picaxe circuit to test very low power consumption, and powered it with 3 not-new AAs. It doesn't do anything except blink a barely-visible LED once every 7 seconds. It's still running: https://picaxeforum.co.uk/threads/low-power-battery-backup-reference-design.8353/ Agree that the real cost is going to be powering the HC-12. I intend to find out about that soon with a similar temperature-measuring task. I will be happy if I can get 6 months out of 3-AAs, waking up about once an hour and transmitting only if there is a nominal temperature change of at least 1 degree (16 16ths of a degree with a DS18B20). PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
Timbergetter![]() Regular Member ![]() Joined: 08/10/2018 Location: AustraliaPosts: 55 |
Grogster, I was wondering if you could tell us a source for DMP2305 that doesn’t involve outrageous shipping costs to Aus? Mouser seem to charge a min of US$24 for that service. |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
RS Components have free shipping. You get 100 for $13.50 rs components Latest F4 Latest H7 FotS |
||||
Page 1 of 3 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |