Raspberry Pi 433Mhz RF Communication Via ATtiny85

The Experiment: In this experiment were going to explore the possibility to replace the Arduino UNO Wireless Weather Station web server, with a Raspberry Pi Web Server. Will use an ATtiny85 to convert the 433Mhz data stream from the remote Weather Station to RS232. The Raspberry Pi will poll the serial port and convert the received ATtiny serial data to .xml file for the flash Web Weather Station plugin.

Table of Contents

1. Project Progress
2. Required Software
3. Raspberry Pi Software Install
Raspbian Debian Wheezy
Set Static IP Address
NGINX
PHP
GNASH
MATCHBOX
UNCLUTTER
4. Hardware
5. Prototype
6. Notes
7. Conclusion
8. Credits

Progress:

Mar 20, 2015: Created a ATtiny 433Mhz to RS232 Data Converter schematic. Built the ATtiny 433Mhz to RS232 Data converter on a proto board and wrote the ATtiny 433Mhz to RS232 sketch. Testing  / working on  the Raspberry Pi Python Serial Port Script.

Installed the NGINX Webserver. Things are looking good weather data .xml file is up dating every second in the background on the Raspberry Pi. Tested the Flash Weather Station Plugin hosted from Raspberry Pi Web server and all working well.

Mar 21, 2015: Decided to boot the Raspberry Pi in kiosk mode, will display the Flash Weather Station Plugin in full screen mode. Will  run the Weather Station 433Mhz to RS232 Data Converter \ Web server in the background. All is working well, the ATtiny 433Mhz to RS232 sketch, Python Serial Port Script have been running without any problems.

raspberry-pi-attiny-433-mhz-rf-communication-dato-converter-to-rs232-wireless-weather-station-prototype-board-kiosk

Mar 22, 2015: Installed Unclutter to hide kiosk mouse pointer.

Mar 26, 2015: Installed PHP. Created wxTrend.py script to store weather trend data for wind, direction, temperature and humidity. Created index.php to display weather trend data with google charts. The serClient.py script which poles the Rpi RS232 port then converts weather data to weather.xml file is working without any problems. The Kiosk display is also working well.

Mar 27, 2015: Now have all the scripts in place, was able to run all weather station applications from the Raspberry Pi and all worked as expected.

Apr 1, 2015: A small problem with the VGA display, looks like it is going out of  sync, but discover that it might be caused by either the  Screen Saver or Blank Screen or Power Saver or Power Down. Not sure which one causing the problem.

raspberry-pi-attiny-433-mhz-rf-communication-dato-converter-to-rs232-wireless-weather-station-prototype-board-down-power-kiosk-screen-saver-power-down

Was able to resolve the problem in console text mode with the following:

1. sudo nano /etc/rc.local

# Add this line to rc.local
sudo sh -c 'setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1' 

2. Ctrl+x-y-<enter>


1. sudo nano /etc/kbd/config 

# Change BLANK_TIME to 0 
BLANK_TIME=0 

# Change BLANK_DPMS to off 
BLANK_DPMS=off 

# Change POWERDOWN_TIME to 0 
POWERDOWN_TIME=0 

2. Ctrl+x-y-<enter>

This resolves the display problem in console mode, but it does not fix’s the problem in X Window Kiosk mode. Working on that problem.

Apr 2, 2015: Might have resolution for display problem in X Window Kiosk mode with the following:

1. sudo nano /etc/X11/xinit/xinitrc

# Insert the following
xset s off     # don't activate screensaver
xset s noblank # don't blank the video device
xset -dpms     # disable DPMS (Energy Star) features

exec /etc/alternatives/x-session-manager # start lxde

2. Ctrl+x-y-<enter>


1. sudo nano /etc/X11/Xwrapper.config

# Change this: allowed_users=console to
allowed_users=anybody

2. Ctrl+x-y-<enter>


1. sudo nono /etc/lightdm/lightdm.conf 

# Under [SeatDefaults] change this: xserver-command=X to 
xserver-command=X -s 0 dpms 

2. Ctrl+x-y-<enter> 


1. sudo nano /etc/xdg/lxsession/LXDE/autostart 

# Change this: @xscreensaver -no-splash to 
#@xscreensaver -no-splash 

# Copy/Past text below 
@xset s off      # don't activate screensaver 
@xset s noblank  # don't blank the video device 
@xset -dpms      # disable DPMS (Energy Star) features 

2. Ctrl+x-y-<enter>

The above kinda resolves the display problem in the X Window Kiosk mode. But it is not consistently working after a shutdown or reboot.

Apr 4, 2015: Since the Kiosk X Window display is still a problem, decided to re-install a clean copy of Raspbian Debian Wheezy, and all the other required programs and script for the experiment. Happy to say that after re-installing everything the Kiosk X Window display has not had a problem. Only used the following settings to disable screensaver, blank video, power saver, power down:

1. sudo nano /etc/rc.local

# Add this line:
sudo sh -c 'setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1' 

2. Ctrl+x-y-<enter>


1. sudo nano /etc/kbd/config 

# Change BLANK_TIME to 0 
BLANK_TIME=0 

# Change BLANK_DPMS to off 
BLANK_DPMS=off 

# Change POWERDOWN_TIME to 0 
POWERDOWN_TIME=0 

2. Ctrl+x-y-<enter>

Have Shutdown -h now, Shutdown -r now many time and so far the Kiosk display has not had a display problems all day. Will test Kiosk display over night. All the other scrips are working fine. Note:  After 2(Two) days of testing still having the same problem.

Apr 6, 2015: Found a none related solution for this display issue on the web. With the following settings: Re-route console system messages from  tty1 to tty9 this stops system messages from displaying on tty1 be-hind the X-Window. Level3 restricts the tty9 system messages to critical errors only. Press Ctrl+Alt+F9 to see system messages, did not try this.

1. sudo nano /etc/rc.local

# Removed this line which was added to rc.local after the re-install:
sudo sh -c 'setterm -blank 0 -powersave off -powerdown 0 < /dev/console > /dev/console 2>&1' 

2. Ctrl+x-y-<enter>


1. sudo nano /etc/kbd/config 

# Change BLANK_TIME to 0 
BLANK_TIME=0 

# Change BLANK_DPMS to off 
BLANK_DPMS=off 

# Change POWERDOWN_TIME to 0 
POWERDOWN_TIME=0 

2. Ctrl+x-y-<enter>


1. sudo nano /boot/cmdline.txt 

# Comment out this line: 
#dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 

# Past this line under that:
dwc_otg.lpm_enable=0 console=tty9 loglevel=3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 

2. Ctrl+x-y-<enter>

Worked all night without any display issues. Well worked all day without any display issues, looks like re-routing the console system messages to tty9 re-solved the display issue. Note: This display issue is possible only related to the way this kiosk has been configured.

Oct 15, 2015: Acquired a  5inch 800×480 LCD Display Module, TFT Resistive Touch Screen Panel with HDMI Interface for Any Model of Rapsberry Pi A+/B+/Pi2.

Raspberry Pi LCD Display Module 5inch 800x480 TFT Resistive Touch Screen Panel HDMI Interface for Any Model of Rapsberry-pi A A+ B B+ 2 B

Interface

PIN NO. SYMBOL DESCRIPTION
1, 17 3.3V Power positive (3.3V power input)
2, 4 5V Power positive (5V power input)
3, 5, 7, 8, 10, 11, 12, 13, 15, 16, 18, 24 NC NC
6, 9, 14, 20, 25 GND Ground
19 TP_SI SPI data input of Touch Panel
21 TP_SO SPI data output of Touch Panel
22 TP_IRQ Touch Panel interrupt, low level while the Touch Panel detects touching
23 TP_SCK SPI clock of Touch Panel
26 TP_CS Touch Panel chip selection, low active

Installation was really simple, and the LCD display worked with some minor changes to the config.txt file.

  1. cd /boot
  2. sudo nano config.txt
hdmi_force_hotplug=1

# Next two lines forces audio through the jack 
# hdmi_drive=1
# hdmi_ignore_edid_audio=1       

# Force 800x480 resolution as this is non-standard for HDMI
hdmi_group=2 
hdmi_mode=1 
hdmi_mode=87 
hdmi_cvt 800 480 60 6 0 0 0 

# Ensure power to the display
# max_usb_current=1

# To get the touch screen working.
# dtoverlay=ads7846,penirq=25

Have not tried the touch screen option yet. Photo below show the Raspberry Pi with 5″ LCD display in kiosk mode, all working just fine, even have some extra space on right side of screen for some more weather data.
raspberry-pi-attiny-433-mhz-rf-communication-dato-converter-to-rs232-wireless-weather-station-prototype-board-kiosk-lcd-800x480-touch-screen

^Top


Software:

Raspberry Pi
1. Raspbian Debian Wheezy
2. NGINX (Web Server)
3. PHP (Hypertext Preprocessor)
4. Python (per-installed with Raspbian Debian Wheezy)
5. GNASH (Flash movie player)
6. MATCHBOX (X window manager)
7. UNCLUTTER (Auto-Hide Mouse Pointer)

Windows PC
1. Putty

^Top


Raspberry Pi Software Install


Raspbian Debian Wheezy .img on SD

1. Download the Raspbian Debian Wheezy here
2. Installing Operating System Images here Linux Mac OS Windows
^Top


Install NGINX

1. sudo apt-get update
2. sudo apt-get upgrade
3. sudo apt-get install nginx
4. sudo /etc/init.d/nginx start

^Top


NGINX PHP

1. sudo apt-get updates
2. sudo apt-get install php5-fpm
3. sudo nano /etc/nginx/sites-available/default
Now edit the name of the server to match your domain.
Note: No domain leave server_name localhost; else server_name <your domain>;

 # Make site accessible from http://localhost/
 server_name localhost;

4. Change the index line from this:

index index.php index.html index.htm;
To this:
index index.php index.html index.htm;

5. Scroll down until you see this:

#location ~ \.php$ {
 # fastcgi_split_path_info ^(.+\.php)(/.+)$;
 # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 #
 # # With php5-cgi alone:
 # fastcgi_pass 127.0.0.1:9000;
 # # With php5-fpm:
 # fastcgi_pass unix:/var/run/php5-fpm.sock;
 # fastcgi_index index.php;
 # include fastcgi_params;
 #}

Uncomment some of the lines so that it reads like this:

location ~ \.php$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 
 # # With php5-cgi alone:
 # fastcgi_pass 127.0.0.1:9000;
 
 # # With php5-fpm:
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 }

6. Ctrl+x-y-<enter>

7. sudo nano /etc/php5/fpm/php.ini
8. Scroll down (or search for the line using CTRL + W in nano) for: ;cgi.fix_pathinfo=1

;cgi.fix_pathinfo=1

Uncomment the line, and change the value from 1 to 0. 

cgi.fix_pathinfo=0

10. sudo /etc/init.d/php5-fpm reload && sudo /etc/init.d/nginx reload

Test the PHP configuration

1. cd /usr/share/nginx/www
2. sudo nano index.php
3. copy/past:

<?php phpinfo(); ?>

4. Ctrl+y-<enter>

5. Launch the browser with <Raspberry Pi IP Address>/index.php

^Top


Install GNASH

1. sudo apt-get install gnash
^Top


Install MATCHBOX

1. sudo apt-get install matchbox
^Top


Install UNCLUTTER

1. sudo apt-get install unclutter
^Top


Hardware:

1. Raspberry Pi
2. ATtiny85 (433Mhz to RS232 Converter)
3. HDMI to VGA Adapter
4. VGA Monitor
^Top


Prototype:

433Mhz to RS232 converter Schematic
raspberry-pi-attiny-433-mhz-rf-communication-dato-converter-to-rs232-wireless-weather-station

433Mhz to RS232 Converter Prototype:
raspberry-pi-attiny-433-mhz-rf-communication-dato-converter-to-rs232-wireless-weather-station-prototype-board
^Top


Notes:

The  Raspberry Pi can now also access the ATtiny  A/D converters.
^Top


Conclusion:

This experiment show that a Raspberry Pi can easily utilize Arduino Libraries though an inexpensive ATtiny micro controller.
^Top


Credits:

1. Tutorial – Install Nginx and PHP on Raspbian
2. Turning Screensavers and Monitor Power saving on/off
3. How do you hide all the boot text

^Top

Advertisements