Nov 272022
 

Straight to the codes.
We’re going to get PMS7003 values and print them to serial monitor.

compile and download these codes to arduino nano

#include ""PMS.h""
#include <Wire.h>  
PMS pms(Serial);
PMS::DATA data;
void setup()
{
    Serial.begin(9600);
}

void loop()
{
  if (pms.read(data))
  {
    Serial.print("PM 1.0 (ug/m3): ");
    Serial.print(data.PM_AE_UG_1_0); 

    Serial.print(", PM 2.5 (ug/m3): ");
    Serial.print(data.PM_AE_UG_2_5); 

    Serial.print(", PM 10.0 (ug/m3): ");
    Serial.print(data.PM_AE_UG_10_0); 
    Serial.println();           
  }  

open serial monitor on Arduino IDE, set the baudrate to 9600 bps, you’ll see the beautifull data coming from PMS7003.
that’s it, pretty simple wight?

Hey!! i want those values grabbed to my raspi zero for my weather station
easy, i can connect PMS7003 sensor serial pin to my raspi UART. but wait, there’s logic level difference between my arduino nano pin I/O and PMS7003.
so, i think the safest way is using usb connect to raspi usb. in my case when i plugged nano to raspi, it will immediately recognized by raspi.

 
pi@raspberrypi:~ $ lsusb 
Bus 001 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 004: ID 1546:01a7 U-Blox AG [u-blox 7]
Bus 001 Device 003: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller
Bus 001 Device 002: ID 2109:2813 VIA Labs, Inc. VL813 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

take a look at

[Bus 001 Device 006: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC]

in my case nano will be on ttyUSB0

pi@raspberrypi:~ $ grep -i 'tty' /var/log/syslog*
/var/log/syslog.1:Nov 20 19:17:23 raspberrypi kernel: [434783.042818] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0
/var/log/syslog.1:Nov 20 19:18:42 raspberrypi kernel: [434861.956242] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
/var/log/syslog.1:Nov 20 19:19:13 raspberrypi kernel: [434892.390729] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0

pi@raspberrypi:~ $ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Nov 20 19:22 /dev/ttyUSB0

let’s get on the python script

#!/usr/bin/env python3
import serial
import time
import sys

#Serial takes two parameters: serial device and baudrate
nano = serial.Serial('/dev/ttyUSB0', 9600)
nano.flushInput()

while True:
    data = nano.readline()
    strs = data.decode().strip())
        print(strs)
    time.sleep(1)

run it, python tne_code_abobe.py

PM 1.0 (ug/m3): 27, PM 2.5 (ug/m3): 40, PM 10.0 (ug/m3): 49
PM 1.0 (ug/m3): 27, PM 2.5 (ug/m3): 40, PM 10.0 (ug/m3): 50
PM 1.0 (ug/m3): 27, PM 2.5 (ug/m3): 40, PM 10.0 (ug/m3): 50
PM 1.0 (ug/m3): 27, PM 2.5 (ug/m3): 39, PM 10.0 (ug/m3): 50
PM 1.0 (ug/m3): 27, PM 2.5 (ug/m3): 39, PM 10.0 (ug/m3): 50

that’s it 🙂

Jul 092013
 

Once upon a time, lifes goes on as usual, boring. Until one day my friend showing me a weird clock on youtube. i said “wow, that was awesome!”, “how it works?”, “i should make one!”. Basically, i have experienced on electronic DIY stuffs. i started to figure out on how to make it, lots of information found. so basicaly, propeller clock based on POV (Persistence of vision)

http://en.wikipedia.org/wiki/Persistence_of_vision

The clock’s graph formed by cheating human eyes, one array of leds burst on constant interval/delay in one motor rotation, continuously (in this case  divided to 360 degree in one rotation, can be more for higher resolution).

After i’ve found, understand, (and yet still confused on how it works :P). i started making prototypes with existing MCU module (atmega8535), wired to array of 8 leds. it works, and not good!! it’s too heavy, no index reference, the text is very unstable. i need to design new board which is lighter and throw out all unnecessary components. there are two web site that i’m using as references, when building this clock.

http://www.microsyl.com/index.php/2010/03/18/propeller-clock/

i used the codes from there with lots of modification, original code is writen using ICCAVR, i converted it to AVR Studio.

http://www.oocities.org/tjacodesign/propclock/propclock.html

i used his isolated power supply, to power up the propeller clock module.

For remote control, it was stolen from here: 😀

http://www.dharmanitech.com/2009/01/ir-remote-controlled-car-pwm-motor.html

picture

Continue reading »