Dimitri KokkonisAyoub Sabri
Published

Getting Started with Sony Spresense and Zerynth

Sony's new Spresense boards offer exciting new capabilities - and Zerynth Studio makes it easier than ever to program them!

BeginnerProtip1,430
Getting Started with Sony Spresense and Zerynth

Things used in this project

Hardware components

Spresense boards (main & extension)
Sony Spresense boards (main & extension)
×1
MikroElektronika BME280 Weather click
×1
Adafruit ALS-PT19 Analog Light Sensor Breakout
×1

Software apps and online services

Zerynth Studio
Zerynth Studio

Story

Read more

Schematics

Sony Spresense Board Pinout

Code

AnalogToDigitalAcquisition.py

Python
import streams  # import the streams module
import adc      # import the adc driver

# create a stream linked to the default serial port

streams.serial()

while True:
    # Basic usage of ADC for acquiring the analog signal from a pin
    value = adc.read(A0)
    print(value)
    sleep(300)

MultiBlink.py

Python
# Initialize the digital pins where the LEDs are connected as output
pinMode(LED0,OUTPUT)
pinMode(LED1,OUTPUT)
pinMode(LED2,OUTPUT)

# Define the 'blink' function to be used by the threads
def blink(pin,timeON=100,timeOFF=100): # delayON and delayOFF are optional parameters, used as default
                                       # if not specified when you call the function

    while True:
        digitalWrite(pin,HIGH)   # turn the LED ON by making the voltage HIGH
        sleep(timeON)            # wait for timeON
        digitalWrite(pin,LOW)    # turn the LED OFF by making the voltage LOW
        sleep(timeOFF)           # wait for timeOFF

# Create three threads that execute instances of the 'blink' function.
thread(blink,LED0)             # D2 is ON for 100 ms and OFF for 100 ms, the default values of delayON an delayOFF
thread(blink,LED1,200)         # D8 is ON for 200 ms and OFF for 100 ms, the default value of delayOFF
thread(blink,LED2,1000,200)     # D5 is ON for 500 ms and OFF for 200 ms

get_values.py

Python
import streams
from bosch.bme280 import bme280

streams.serial()

try:
    # Setup sensor
    print("start...")
    bme = bme280.BME280(I2C0)
    print("Ready!")
    print("--------------------------------------------------------")
except Exception as e:
    print("Error: ",e)

try:
    while True:
        temp, hum, pres = bme.get_values()
        print("Temperature:", temp, "C")
        print("Humidity:", hum, "%")
        print("Pressure:", pres, "Pa")
        print("--------------------------------------------------------")
        sleep(5000)
except Exception as e:
    print("Error2: ",e)

Credits

Dimitri Kokkonis

Dimitri Kokkonis

5 projects • 4 followers
EE/CS student majoring in Embedded Systems at Polytech Sorbonne, Paris.
Ayoub Sabri

Ayoub Sabri

5 projects • 5 followers
Embedded Systems student at Polytech Sorbonne (Paris)

Comments