There can be no doubt that I still have some way to go in terms of reliability with my test rig in Spain before putting this stuff in charge of the heating back home in the UK:
- Raspberry Pi 2 is on an un-interruptible supply but does not 100% recover from loss of broadband. One example made my Apache instance disappear until I rebooted the Pi !! I’ve just instigated a check for Google connectivity every 15 minutes leading to a reboot if no success – hoping this will solve the problem.
- ESP8266 board mostly recovers from power failure but I have one example of it simply not communicating until next power cycle. Will soon do some tests removing the power for various periods from milliseconds upwards.
Other than these points, I’m starting to get somewhere. I have plant-watering control running, a kitchen light under dusk to midnight control using my Node-Red scheduler referred to elsewhere – and as of this morning I’m logging external temperatures locally every 15 minutes using MQTT and Node-Red to ask for temperature, MQTT, Node-Red and MYSQL to store the temperature (as read by a DS18B20 using my own ESP8266 fast code) and local HighCharts and PHP to read the temperature from the DB (including missing values) on a chart on the Pi (up to now I’ve always used GroveStreams for everything but I’d like to try storing information locally). I’ve documented all of this in previous blog entries. At some point I want to scrap the PHP and use JS within Node-Red.
Building up to this seems such overkill – but then now it is done, the sky is the limit – setting these up (below – and remember – click on any image to show full size version) took no time at all. I used the scheduler with a new addition to my little ESP board, a timer option which turns the output (ESP-01 for example) on on request for X minutes – the board then turns the output off all on it’s own.
So for the watering I just sent the same message at dusk and dawn, a timed request for 4 minutes of watering. I figured dusk and dawn were as good a time as any and no chance of blasting hot water onto the plants (believe me, in Spain if you try this at lunchtime from a typical black pipe watering system, you’ll fry the plants).
The lower block above simply puts out the temperature request every 15 minutes and above that an MQTT block picks up the incoming temperature and fires in insert command off to the MQTT node.
Meanwhile I’ve been pondering a device I’d not specifically come across until yesterday, the Si2302 N-channel MOSFET. From EBay these work out at a few pence each (like, 3p in quantity) and are simply tiny SMT devices (but large enough to solder by hand). I’m thinking these might do for powering LED strips, both simply on-off control and PWM. If I’m reading the spec right, these should work just fine from the 3v + output of an ESP8266 with no other components (no base resistor for example) and with 1 amp’s worth of LED STRIP (12v) attached I reckon the chip should dissipate no more than 80mw. Of course my maths could be miles out but I’ve a few samples on the way to give this a shot and if they pan out I’ll stick them on the next board.
Has anyone had any experience of this particular MOSFET?
And so that leads me to a question. What if the router is giving an IP address… but there is no connection to the outside world? Perhaps the Internet provider link has gone down? I’m not sure all programs will handle this?
From the point of view of the script I shared, it wont’t do anything. If it has an IP, it will keep the current wifi connection, there’s no need for wifi reset.
I’m not fully understanding what kind of programs you mean.
Hi Peter.
About the auto connect I’ve a small bash script (based in some post in the raspberry pi forum), that is called every 15min by the crontab
*/15 * * * * sudo ~/./network-monitor.sh
###################################################
#network-monitor.sh
###################################################
#!/bin/bash
if ifconfig wlan0 | grep -q “inet addr:” ; then
sleep 10
else
echo “Network connection down! Attempting reconnection.”
ifup –force wlan0
sleep 10
fi
######################################
Do I take it Luis that this resets the WIFI as against rebooting the PIO? Do other programs work well with this?
Yes. It check if WIFI (wlan0) has an IP. If not it attempts an new connection. It should be transparent to any running program in your PI…
I’m using this script to assure reconnection if my router reloads.
Hello, I had the same problem (raspberry not recovering from loss of wifi broadband) until I tried the most voted solution here : http://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi
and it seems to be working.
Cheers!
Beginner question, why not use an optocoupler?
Hi Oliver… not quite seeing the point – why would I want to use an opto-coupler for low voltage? Now, if switching mains power then there are two general options – first is a relay – and that needs a transistor – so these (cheap) mosfets would do that also… OR I use a solid state relay or opto-triac.
Si2302 are fine for switching LEDs, just do not exceed the power rating, about 1A is fine. If you order from ebay and seller is near China it is most likely to have marking “A2SHB”. Not genuine Vishay part but work as well.
For a higher current you may consider AO3400A, same SOT-23 package but a little beefy.
Oh thanks for that Baoshi – as you say they ARE more beefy – but accordingly more expensive. With a maximum power dissipation of 1.4w I’m guessing they’ll handle WAY more power. Well I was just looking – and a friend had pointed these out as cheap. I see a use for both – your A03400A for driving LED strips and the Si2302 for handling relays etc. Hmm.. right I’m off to Ebay.
The AO3400A are showing up on ebay at under US$0.08 each in lots of 100.
I would still be tempted to use a resistor (somewhere around 100 ohm to 1k) between the GPIO and the gate, mainly for protecting the ESP8266 in the rare occurrence of a short on the MOSFET, or a solder or PCB short. Also the resistor gives you some other options, like diode logic, etc.
Good advice Ken. it looks as if they are pin compatible with the NPN transistors we use – which is handy.