RoadTest: Raspberry Pi 3 Model A+
Author: embeddedguy
Creation date:
Evaluation Type: Development Boards & Tools
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?: Single board computer with connectivity.
What were the biggest problems encountered?: I think dealing with SD card image's as they are very fragile. For MQTT I required 2 Pis at the same time.
Detailed Review:
This is not a final draft for the road test. I will update it as I make progress. Give your suggestions below.
Thank you element14 and Randall Scasny for giving me the opportunity to do this road test and providing the RaspberryPi 3 A+.
For those who don't know a RaspberryPi, it is a single board computer with various functionality onboard Like, GPIOs(General Purpose Input/Output pins), USB ports, HDMI, display and camera connector All in one board!!
while a lot of embedded development boards and tools are difficult to work on, Raspberry Pi is not like that. The problem with embedded boards is mostly related to getting started smoothly and then develop something useful and keep the progress alive. Maybe one will be able to start creating an introductory project like blinking an LED and then he/she will have to look for the long datasheets for the next bit advanced task. This is not a challenge for an individual but for everyone who starts developing something with MCU/MPU boards. Raspberry Pi is somehow out of all these problems. first, it is very easy to get started with the Pi. There are pretty easy to follow tutorials and guides which runs without any error or issues. One can do something with a camera, sensor interfacing, connectivity, etc quite easily. it runs Linux based OS(some other also like windows IOT) from a small SD card. All these features make it a tool to develop something in IOT, Home automation projects, Cloud connectivity projects or to do some of the industrial automation tasks.
Raspberry Pi 3 Model A+ is the newest Raspberry Pi model and it features with the following configurations.
The Raspberry Pi 3 Model A+ extends the Raspberry Pi 3 range into the A+ board format.
I have decided to make some sensor-based IOT project. The official SenseHat from RaspberryPi foundation is I think well known to everyone. It is an official board with multiple sensors and LED matrix on it. It is also launched at the international space station.
https://www.raspberrypi.org/products/sense-hat/
I am using the sense-hat with Raspberrypi to send data over an MQTT protocol. MQTT is a lightweight protocol used to send data over the internet. it has a client, server, and brocker who communicates with each other. In the following scripts, the first script is from the server which sends the sensor data like temperature, pressure, etc. the iot.eclipse.org is the broker who manages the communication by name and ID. The second script is the one which runs on the client which gets the data of the sensors on the command line. I will show you some steps required to do the following project.
You will need either one or in best case two RaspberryPi (one for the subscriber and other for the publisher node) else you can also use your laptop for subscription to MQTT messages. I am using raspberryPi for both.
First thing is to install Paho MQTT software.
https://www.eclipse.org/paho/clients/python/docs/
pip install paho-mqtt
After the installation is done make a python file for the publisher and paste the following code in the file in publisher Pi.
from sense_hat import SenseHat import time import string import paho.mqtt.client as mqtt import paho.mqtt.subscribe as subscribe sense=SenseHat() sense.show_message("Sense") client=mqtt.Client() client.connect("iot.eclipse.org", 1883, keepalive=60) while(True): print("\n") humidity=sense.get_humidity() time.sleep(2) temp=sense.get_temperature() time.sleep(2) temp1=sense.get_temperature_from_humidity() time.sleep(2) pressure=sense.get_pressure() client.publish("temp", temp) client.publish("pres", pressure) client.publish("humy", humidity) print("Humidity %s" %humidity, "temprature %s" %temp, "Pressure %s" %pressure) #msg=subscribe.simple("temp", hostname="iot.eclipse.org")
After that make a subscription.py file in the subscriber Pi and paste the following code.
import paho.mqtt.subscribe as subscribe import paho.mqtt.client as mqtt client=mqtt.Client() client.connect("iot.eclipse.org", 1883, keepalive=60) topics=["temp", "pres", "humy"] def on_message_print(client, userdata, message): print("%s %s" % (message.topic, message.payload)) while(True): subscribe.callback(on_message_print, topics, hostname="iot.eclipse.org")
SPI testing with a current sensor.
There is a C++ library called wiringPi for SPI and I2C functions. Apart from that one can also use Broadcom's native library functions. I came to know the latter a bit latter . So I used WiringPi. The current sensor from Infineon is able to measure the current based on the magnetic hall effect. It offers SPI and I2C interfaces. You can find the details of the sensor on the following link.
https://github.com/raspberrypi/linux/blob/rpi-3.12.y/drivers/spi/spi-bcm2708.c
SPI normally has four wire interface. But this sensor from Infineon(TLI4970) has no MOSI as it continuously sends two kinds of data packets, both 16 bits wide
STATUS bit> Indicates the status of the sensor, usually sensor sends this bit on startup or malfunction
Message bit> this is the value of current send by the sensor.
CS> To select the slave device.
SCLK> To provide the clock source
MISO> Master In Slave Out
MOSI>Master Out Slave In
#include <wiringPi.h> #include <stdio.h> #include <stdlib.h> static const int CHANN=0; int main() { unsigned int buffer[1000]; int status; buffer[0] = 0x0000; wiringPiSetup(); wiringPiSPISetup(CHANN, 500000); wiringPiSPIDataRW(CHANN, &buffer[0], 2); printf("\nReceived value from sensor=0x%x", buffer[0]); buffer[1]=buffer[0]; status=checkmessage(buffer[0]); printf("\nStatus bit: %d\n", status); if(status==0){ get_current(buffer[1]); } } int checkmessage(unsigned int s) { int k; k=s>>15; if((k&1)==1){ printf("\nThere is no current"); return 1;} else{ return 0; } return 0; } int get_current(unsigned int a) { int j=1,k; float x=0; int current_accu=0; for (int i=0; i<=12; i++) { k=a>>i; current_accu+=(k&1)*j; j=j*2; } printf("\ndecimal value of current %d", current_accu); x=(0.01220*current_accu)-50; printf("\nCurrent in Amps %f\n",x); return x; }