31 December, 2019
29 December, 2019
28 December, 2019
27 December, 2019
05 January, 2019
Raspberry Pi and 3d printed Rain meter - Part 3 - Solution Structure
In this part I will briefly describe my solution / architecture.
Broadly speaking this is my overall use case:The Raspbeery pi will take the measurements. The Contabo (Ubuntu) server will use these measurements and formulate the rainfall, and make it available for consumption onto the internet (Example: Web page, API, SMS Telegram Bot)
Something must be built to check if the Raspberry Pi is up and running, and user (me) alerted when not able to be reached.
In future more more sensor data can be added.
This is my solution for the Raspberry Pi:
Broadly speaking this is my overall use case:The Raspbeery pi will take the measurements. The Contabo (Ubuntu) server will use these measurements and formulate the rainfall, and make it available for consumption onto the internet (Example: Web page, API, SMS Telegram Bot)
Something must be built to check if the Raspberry Pi is up and running, and user (me) alerted when not able to be reached.
In future more more sensor data can be added.
This is my solution for the Raspberry Pi:
- SQLite database to store the tips.
- Command line program (aka sensorDeamon) that will be systemded to listen and save the tips to the db.
- The SensorDeamon will also send out an alert that a tip has occurred.
- An nginx hosted API to give remote access to the SQLite data.
- An nginx hosted API that will listen for alerts.
- On receiving an alert it will go and retrieve all data since last retrieval from the RPi.
- Do the calculations, and store data in Postgres database.
- Make this data available via:
- SMS (Send me an alert when it starts raining)
- Web (So I am other people can view the info and history)
- API (Other systems can query my data)
- Telegram (Get alerts and stats via telegram
- I would have loved to have done something for Whats app, but there is no public API available for it.
- sensorpi
- configs
- database
- scripts
- sensordeamon
- webapi
- sensorpi just holds the whole solution in one place.
- configs folder will contain the configuration settings for:
- sensordaemon, and
- webapi
- This will allow me to put the source code onto git without revealing my private passwords and settings.
- Since the database only exists on the Pi and I dont have a dev I will put the database script in a sub folder and shell file for me to recreate it as needed.
- sensordeamon wfolder will contain the command line app that listens to the tips.
- webapi will allow remote access (from the Ubuntu server) to my database.
Raspberry Pi and 3d printed Rain meter - Part 2 - Loading and testing dotnet core
I am a c# developer by day, and although I can kind of work in Python, I dont like it.
Since dotnet core now runs on most Linux systems including the Raspberry Pi, I thought I would give it a go and see how it works. Only problem might be talking to the GPIO pins on the board but I am sure I can find some type of solution
Since dotnet core now runs on most Linux systems including the Raspberry Pi, I thought I would give it a go and see how it works. Only problem might be talking to the GPIO pins on the board but I am sure I can find some type of solution
- Loading dotnet Core onto the RPi
I followed the instructions on this page with a few minor changes after I ran into trouble.
These are the commands I used:
$ apt-get install wiringpi
$ sudo apt-get -y update
$ sudo apt-get -y install libunwind8 gettext
$ wget https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.300/dotnet-sdk-2.1.300-linux-arm.tar.gz
$ wget https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/2.1.0/aspnetcore-runtime-2.1.0-linux-arm.tar.gz
$ sudo mkdir /opt/dotnet
$ sudo tar -xvf dotnet-sdk-2.1.300-linux-arm.tar.gz -C /opt/dotnet/
$ sudo tar -xvf aspnetcore-runtime-2.1.0-linux-arm.tar.gz -C /opt/dotnet/
$ sudo ln -s /opt/dotnet/dotnet /usr/local/bin - SSH Deploy to the rescue.
I have VS2017 installed on a windows PC, and decided to use that for my development environment but there is a problem ... How do I easily get the code from my Windows PC onto the RPI to test. Luckily I found this program called SshDeploy. This made my life much easier.
Following the instructions on the site I installed it added the xml tags to my project and tested it. Each time after a successful compile it auto sends the program data to the pi.
- Finding a Nuget Package for the GPIO pins.
Next thing was to proof that I can communicate with the GPIO pins correctly. I did a search on NUGET for GPIO and went to each web site to see how much info there was in case I got stuck. I settled on Unosquare Raspberry IO.Lots of help and a good description. What sold me on the solution was the ability to use callbacks so no need for a while (true) loop. - Testing the GPIO pins.
I created a new dotnet core 2.1 command line program, followed the steps of SSH Deploy and added this code:
using System;
using Unosquare.RaspberryIO;
using Unosquare.RaspberryIO.Gpio;
namespace TestGpio
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Gpio Callback Test 3");
var pin = Pi.Gpio.Pin00;
pin.PinMode = GpioPinDriveMode.Input;
pin.InputPullMode =
GpioPinResistorPullMode.PullUp;
pin.RegisterInterruptCallback (
EdgeDetection.RisingAndFallingEdges,
Pin00Callback);
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
static void Pin00Callback()
{
var pin = Pi.Gpio.Pin00;
var state = pin.ReadValue();
Console.WriteLine("Pin Activated..." + state);
}
}
}
- I compiled the code, and confirmed it SFTPed it to the Raspberry Pi.
- I logged into the RaspBerry Pi with my user name and went to the deployed folder and verified the files were recent.
- Then I ran the program using this command:
$ sudo dotnet TestGpio.dll - This is the output:
Raspberry Pi and 3d printed Rain meter - Part 1
See the Introduction.
As a side note:
This is where I buy my components from. Luckily I had them all already.
As a side note:
This is where I buy my components from. Luckily I had them all already.
- G T Electronic Components
- Roleen Electronic Components
- Micro Robotics (In Centurion)
- I downloaded Raspbian Stretch Lite from the official web site.
I downloaded the lite version as I have no need for a desktop. - I downloaded Etcher from their web site.
- Since my Pi had an existing 4Gig SD Card I just used that, and put the image on the SD card following the instructions from here.
- I booted up the pi, and all was well.
- I then enabled wifi, and remote ssh login.
- I then created a new user for myself to log in with rather than the "pi" user.
- I then searched google for "hall sensor raspberry pi" and found this web site. and followed all the instructions there, but will repeat them here for clarity in my own words.
- I built my little circuit on a breadboard.
- I then created a new folder in my home folder on the pi called "hallsensortest" by executing this command:
mkdir hallsensortest - Go into the folder by
cd hallsensortest - And then executing the command to get the python script from bitbucket
wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/hall.py
- Since I had logged in using my own user name (and not pi [good security practice]) I had to execute:
sudo python hall.py
The reason for the sudo is to gain access to the GPIO pins with elevated privileges. - Then all that was left to do is test it. I got a magnet and waved it in front of the hall sensor, and the screen updated accordingly.
04 January, 2019
Raspberry Pi and 3d printed Rain meter - Intro
I decided to try and build something using my Raspbrry Pi.
A work colleague had said he had built a weather station to 80% completion and had 3d printed the rain meter.
I then asked if he would be so kind as to print me one as well and I would build it over the December holiday. As I was busy with other things so I only started this project in the new year (2019).
This is what the 3d printed rain meter looks like:
The lid (3) guids the rain drops into the center, which then drips into the tipping bucket (2). A very small amount of rain will make it tip, let out the water through the hole (4) and put the other side of the bucket (2) ready to catch more water. There is a small thin magnet (yellow line) attached to the tipping bucket (2), and this will activate a hall sensor attached to the raspberry pi (see Part 1 for more details)
I suspect I would have to sand the lid (item 3) down a bit to make it smooth for the raindrops. And paint it with a UV resistent paint to guard it against the African sun.
The yellow line I suspect is where the magnet will be attached once I assemble the whole thing.
The plans can be downloaded from thingivers if you want to print your own.
Part 1 - Testing the hall sensor
A work colleague had said he had built a weather station to 80% completion and had 3d printed the rain meter.
I then asked if he would be so kind as to print me one as well and I would build it over the December holiday. As I was busy with other things so I only started this project in the new year (2019).
This is what the 3d printed rain meter looks like:
- Is the main container.
- Is the tipping bucket
- Is the lid that goes on the top to guide the rain drops over the tipping bucket.
- Is the outlet hole (one each side)
The lid (3) guids the rain drops into the center, which then drips into the tipping bucket (2). A very small amount of rain will make it tip, let out the water through the hole (4) and put the other side of the bucket (2) ready to catch more water. There is a small thin magnet (yellow line) attached to the tipping bucket (2), and this will activate a hall sensor attached to the raspberry pi (see Part 1 for more details)
I suspect I would have to sand the lid (item 3) down a bit to make it smooth for the raindrops. And paint it with a UV resistent paint to guard it against the African sun.
The yellow line I suspect is where the magnet will be attached once I assemble the whole thing.
The plans can be downloaded from thingivers if you want to print your own.
Part 1 - Testing the hall sensor
01 January, 2019
Plans for 2019.
My plan was to build a raspberry pi based robot in 2017.
I bought an extra Raspbery Pi 2 end of 2016 with a camera, and a battery pack.
I never got so far as building it.
My long term plans are to build a grandfather clock, it will be the grandfather clock to end all grandfather clocks. But that finished product is still 10 or so years away. Lots of other things need to take place fist before I get to that project.
I work colleague, has a 3d printer, and has some amazing projects that he is busy with. From 3d printed planes, to cnc machines.
Also Trish and I keep track of the rain fall in our suburb. She takes the reading, then WhatApps it to me and I add it into my Diary (a spreadsheet). We have been keeping track of it for 3 year so far. Btw the rainfall in Isandovale for the last 3 years was:
However I decided I would first build it using my Raspberry Pi. So after completing a few other (video) projects I started with the Rain meter project. The details will be in a separate blog post.
So my plans for 2019 are:
I bought an extra Raspbery Pi 2 end of 2016 with a camera, and a battery pack.
I never got so far as building it.
My long term plans are to build a grandfather clock, it will be the grandfather clock to end all grandfather clocks. But that finished product is still 10 or so years away. Lots of other things need to take place fist before I get to that project.
I work colleague, has a 3d printer, and has some amazing projects that he is busy with. From 3d printed planes, to cnc machines.
Also Trish and I keep track of the rain fall in our suburb. She takes the reading, then WhatApps it to me and I add it into my Diary (a spreadsheet). We have been keeping track of it for 3 year so far. Btw the rainfall in Isandovale for the last 3 years was:
- 2016 - 458 mm
- 2017 - 689 mm
- 2018 - 593 mm
However I decided I would first build it using my Raspberry Pi. So after completing a few other (video) projects I started with the Rain meter project. The details will be in a separate blog post.
So my plans for 2019 are:
- More blog posts for the 2 people who read them.
(It actually is just a diary for myself) - Create a rain meter using the Raspberry Pi.
- Create a small
CNCpen plotter machine using floppy drives (like this). - Create a bigger CNC using NEMA17 motors like this.
- If there is time enhance the rain meter into a weather station.
Subscribe to:
Posts (Atom)