This tutorial will take you step by step to get your PICAXE to upload sensor data to the internet. You can also poll the internet for data such as switches or in this example the forecast rain for you city.
- Raspberry Pi Model B
- 8GB SD Card
- Bluetooth Master HC-05 (Connect to PICAXE)
- Bluetooth Slave HC-06 (Connect to Pi)
- PICAXE Motherboard and ProtoPlatform (and programming lead)
- Jumper Wires
Set up your Pi:
- Go to the official raspberry pi website and follow the NOOBS setup instructions to easily install the newest version of RASPBIAN: http://www.raspberrypi.org/help/noobs-setup/
- Before you start the Pi in Graphical User Interface mode (GUI) you should configure a few settings in the raspi-config. This menu should open up automatically but if it hasn’t or you already have the pi set up you can get to it by typing “sudo raspi-config” the command line.
- Internationalisation Options -> Change Timezone
Change the timezone to your appropriate area.
- Advanced Options -> Serial
You will be asked “Would you like login shell to be accessible over serial?” and your current setting will be displayed. You will need to select <No> so that the bluetooth serial data wont be interrupted by serial information set by the system processes.
- Internationalisation Options -> Change Timezone
- With these two settings configured you can exit the setup and login to the pi using default user: pi and password: raspberry. Once you have the pi started to a command line type STARTX to enter the graphical interface mode.
- From the desktop you can open a internet browser such as NetSurf and navigate to this page then download this file: senseserver.py.
- Using the File Manager (Start -> Accessories – > File Manager), check that the files is in the “/home/pi” folder. If it isn’t then more it to this folder.
- The Pi is now setup but you will need to setup the Picaxe and the Bluetooth Modules before the senseserver.py will do anything.
Pi Optional Steps / Trouble Shooting:
- Setup SSH (and VNC) if you don’t have a screen to easily connect to.
- I think the newest versions of Raspbian are setup to use the serial port at 9600 rather than 115200 but if you are having issues check out this post (Note: part of these steps were already handled in the raspi-config in Step 2).
Slave Bluetooth Setup:
- You should have purchased two different bluetooth devices the one that is connected to the Raspberry Pi is the JY-MCU use the wiring diagram:
- I found it is best to configure the Bluetooth modem via the Raspberry Pi in GUI mode using the LXTerminal. I found it impossible to type the AT Commands fast enough before the device would try and respond. I ended up copy and pasting the AT Commands into the terminal which worked much better. The following blog post is what I used to learn to do this, I will try and keep the instructions brief if you need more info you should check out the source of the information.
- In the LXTerminal use the following command to install Minicom:
sudo apt-get install minicom
- Start Minicom terminal with the following:
minicom -b 9600 -o -D /dev/ttyAMA0
- Press Ctrl + A on your keyboard which will bring up a grey bar at the bottom of the screen press “Z” for more options.
- From the help menu turn on echo by pressing “E”. This will allow you to see the information you send in your local terminal.
- Copy and paste the following AT commands from this website into the LXTerminal:AT
Response should be: “OK” if your device is responding properlyAT+NAMESENSE
Response should be: “OKsetname”AT+PIN4321
Response should be: “OKsetPIN”
- Your slave bluetooth device connected to the Pi should now have the following settings (or your own but need to match them with the second device).
NAME = SENSE, PIN = 4321
Master Bluetooth Setup
- Now you will need to complete a similar process with the master BT device HC-05 by plugging the Bluetooth device into the Pi. I used these instructions but again I will provide some simplified instructions and if you get lost then check out the source.
- Plug the HC-05 device into the same Raspberry Pi GPIO Pins (i used a breadboard and some jumper wires). You should have the GND, 3.3v, TXD, and RXD pins connected. You will need to collect the KEY pin to the 3.3V pin with a jumper wire to put the device into AT mode.
- Disconnect the GND pin and reconnect to ensure the KEY and 3.3v pins are when the device starts. This should have put the Device into AT Mode and the LED should flash every 2 seconds.
- Start a minicom session with the following settings (38300 is the baud rate when the device is started in AT mode with the key pin connected high):
minicom -b 38400 -o -D /dev/ttyAMA0
- Test the collection by typing AT and pressing enter on your keyboard and you shold receive an “OK”. (Note: The HC-05) allows the user to send the line return before responding).
- Complete the following AT commands:AT+ROLE=1
Puts device into Master Mode
Connects to any BT device. (Note: can be turned back to “0” once paired and then device will only pair to the most recent connection).
Changes the name of the bluetooth device to “SENSEMAST”
Changes the passkey
Sets the baud rate for the PICAXE to communicate to the device
- If you need more detailed information checkout the HC-05 manual for all of the AT commands.
- Now the Master Bluetooth device needs to be removed from the Pi and connected to the PICAXE. You can also reconnect the Slave Bluetooth HC-06 to the Pi.
- On a 20M2 PICAXE CHIP connect the Bluetooth HC-05 to the following pins:
GND – GND
3.3 – NC
5.0 – V+
TXD – C.7
RXD – B.0
KEY – NC
- Connect appropriate sensors that you would like to sue and modify the following PICAXE program to suit your needs: