RPI Jessie and Ping

I was having some issues the other day with SD Card corruption, just after a few hours use and a few reboots the card was done. So I opened ApplePi-Baker and got ready to re-flash the card. Then I thought it had been a while so I went to see if there was a new distro, I don’t really keep up. In fact yes there was, Jessie was now available. Sweet.

So far I have not really noticed any issues (other than this one) with Jessie. It even has Node-RED out of the box. But I couldn’t figure out why my presence detection flow wasn’t working. It was working just fine before I switched from Wheezy to Jessie and yes I did install the Ping node required. I could ping my phone so what was up? I decided to try and ping my phone from the RPi. AHA! That was the problem.

Trying to run a ping resulted in ping: icmp open socket: Operation not permitted

Say wuh? Some quick Googling and I found this thread at the Ubuntu forums.

Run command ls -l `which ping`. If it does not look like this -rwsr-xr-x 1 root root 30856 2007-07-06 02:40 /bin/ping then that is why. The important part is the “s”.

-rwsr-xr-x 1 root root 30856 2007-07-06 02:40 /bin/ping

If you don’t have an “s” run this command to fix it: sudo chmod u+s `which ping`. You should be able to ping away to your hearts content now.

The Node is Red Long Live The Node

The Node is Red, long live the Node! I got back into the Pi recently after a few months off of fiddling with it. I had already made the sub board for the alarm, I decided to remake the temperature board as well (it didn’t work either). So I had the boards ready now I needed the software. I could try to put back together the original scripts I had, or I could just start fresh. I decided to start fresh. While Googling something (I don’t remember what) I came across Node-Red. Completely unfamiliar with it. I have seen Node.js here or there but thats it. Looked a little further and then I installed it. It’s awesome really. I am nit the best at Javascript so it’s a curve to me but the GUI makes up for that. I got Node-Red up and running on the Raspberry Pi in about 15 minutes. I won’t go into install details as they are out there already. What is not out there, or at least is very hard to find, are examples of GOOD flows, or tutorials on how to get things done. Like what code is needed to do the simple things, but I guess they are expecting you to know that already.

Getting Node-Red installed was easy, besides not finding much help on the web I also didn’t realize that you need to install all the modules you will be using before hand. So things like Twitter, Pushbullet, BMP temp sensors won’t work until those modules are installed. Installing was no problem, but it took the little RPi forever to install them all. I would say it took the better part of half a day to search and get them all loaded.

Because of the lack if examples (and my lack of JS) it took me a few days to figure out how to grab part of the URL and pass it to a page to spit it back at you. Simple right? So here it is, copy and pasted in all its glory (taken from http://sharpk60.blogspot.com/2014/10/first-steps-with-node-red.html):

Raspberry Pi High CPU Utilization

So if you are coding in python for your Raspberry Pi and your script runs a loop you may have noticed the high cpu utilization, or not. I have not had an issue (yet) with the Pi running in the 90%, I have had a test Pi on my bench running for a few days with no problems so far. Least to say that it still is an issue.

Now I cannot claim to be the author of this fix, I found it while digging through the RPi forums one day. If your Pi is having this issue, simply add this line of code here and there during your loop:

time.sleep(0.1)

TA-DA! It really is that simple. I added one time.sleep(0.1) call between each of my IF/THENs and I watched (via top) my cpu go from 90-98% to under 5%!!

My adventures in 433mHz with a Raspberry Pi B+

So I bought some 433mHz modules off of eBay for dirt cheap. The “standard” 4 pin receiver and 3 pin transmitter. For the life of me I could not get them to work. Everything I found online appeared to be related to the RPi A I am pretty sure because NONE of the instructions worked for me. I was able to download, compile and run the commands but with zero results. I tried damn near all tutorials I could find out there. Nothing work but I did get close a few times. The part that really irritated me was that I had hooked up LEDs to the Tx and Rx pins to see if it was working. It was, I could see the LEDs flicker away when I pressed buttons, but no results with sniffing.

Finally I was able to send and receive a signal. RFSniffer finally worked off of pin 13/GPIO 27/wiringPi 2 on my Raspberry Pi B+. I curse the people that decided to use a completely different number schemes!! I used this http://shop.ninjablocks.com/blogs/how-to/7506204-adding-433-to-your-raspberry-pi to get the sniffer working, with the above pins, but without the ninja block stuff.

I don’t have FTDI, it hasn’t arrived yet, so I used my Arduino Duemilanove to flash the Mini Pro, but it didn’t work. To get the Arduino Mini Pro to flash I had to switch the Tx and Rx pins. You will find all the directions out there say to connect the Arduino’s Rx to the Minis Tx and vice versa, but that was not the case for me. I did find one post on the Arduino forums that mentioned switching them, I had to flip-flop the pins and then it worked! Tx to Tx and Rx to Rx. I got my Mini Pro off eBay for cheap, it has no name on it, but it does have a red PCB and a small Sparkfun logo. Works like a charm this way. Just remember to set the Arduino IDE to your Mini Pro or you will get errors. I also HAD to remove my Duemilanove’s chip to flash the Mini. I tried it with it in and it did NOT work.

As for the receiver some say to use 5v to power, the board even says 5v. But I have also read people using 3.3v to power it. I used 3.3v to power it when I was testing. To use 5v and the RPi you need to drop the voltage or you will damage the Pi. Use a voltage divider with a 1K and 2K ohm resistors to do it. Google Images has plenty of examples. http://forum.arduino.cc/index.php?topic=136788.0

Heres the code I used to finally get it to work:

———————
(1) Raspberry Pi B+
(1) XY-MK-5V 433mHz Receiver (4 pins, both data are the same)

(1) Arduino Mini Pro
(1) FS1000A 433mHz Transmitter (3 pins)

RFSniffer (on the RPi for receiving)
RCSwitch (on the Arduino for transmitting)

I used 2 LEDs on the Tx and Rx data pins, and 10K ohm pulldown resistor for the button. I also soldered on 17cm (about 6.5″) of 22awg solid copper wire for antennas.
———————

Some useful links
http://arduino.cc/en/Tutorial/ButtonStateChange

So far so good. Do not blame me for anything bad that happens to you or your RPi/Arduinos, consider yourself warned. Double check your wiring!!