Before we are getting started with IoT and programming – we need to get our environment ready. Preparing the environment includes installing some tools and drivers. It won’t take long, just follow along with the guide and you should be ready in no time! The Eduponics Agriculture learning kit is one of the most sufficient kits available in the market. Contains everything you need for getting started with IoT development and building smart agriculture applications.
Connecting the kit to the power #
The Eduponics Mini board includes 2 power interfaces.
- DC 12V Power interface
- USB Type-C 5V Power interface
It’s possible to power the board with 5V USB Type C through the USB ports available on your computer.
The USB Type-C should be used only for programming and not be used for general operation. Due to the voltage not being enough to power some of the development board functionalities such as the 12V pump.
Once you’ve finished programming, use the 12V power adapter to power your project. Some modules and sensors such as the water pump and the relay require 12V. If you are unable to provide 12V input, some parts of the board might bring instability and unexpected results.
Powering the board with 12V and 5V power at the same time is completely safe. This won’t cause any damage to the board.
Only use Eduponics mini supplied DC Power adapterOur Eduponics Mini 12V2A power adapter is RoHs, CE and FCC certified.
The power adapter passed the most critical tests to ensure your safety and the safety of your project. The use of any other unofficial power adapter might result in damage to you or your project and we are not liable for the outcome
Installing USB TTL Drivers #
If you looking on getting started with IoT development, you first need to learn how to communicate with the IoT board. In order to do that, we will learn about serial communication and programming. The USB TTL Serial cables are a range of USB to-serial converter cables which provide connectivity between USB and serial UART interfaces,
In our kit, we include a USB Type-C cable that can communicate with the Eduponics Mini board. The USB cable is mostly designed to upload/download code from and to the ESP32 board.
The Eduponics mini UART (serial communication) port is based on the CH340C driver. This driver is a USB to TTL chip to convert the USB signal to serial communication. To make sure your computer can read/write from the Eduponics mini ESP32 kit, we need to install some drivers.
Some computer systems might include support for it but some don’t. If the driver doesn’t work for you right away, you might need to follow the instructions to install the driver.
Windows and OSX drivers automatically installedIf you have Windows or Mac system, The latest version of the Universal Driver should be automatically installed from a Windows Update or included with the OSX System pre-installed. On other systems you might need to download and install the drivers manually.
Note: after installing the drivers, a system reboot might be required.
IDE or Code Editor #
The term “IDE” stands for “Integrated Development Environment”. It is intended as a comprehensive toolset including a text editor, compiler, build/make integration, debugging, and so on. Virtually all IDEs are tied specifically to a language or framework or a tightly collected set of languages or frameworks. Some examples are visual Studio for .NET and other Microsoft languages, RubyMine for Ruby, IntelliJ for Java, and XCode for Apple technologies.
An editor is simply, a tool that is designed to edit text. Typically they are optimized for programming languages though many programmers’ text editors are branching out and adding features for non-programming text like Markdown 108 or Org Mode 88. The key here is that text editors are designed to work with whatever language or framework you choose.
There are many available IDEs and code editors that support MicroPython and will enable you on getting started with IoT. In STEMinds, we prefer to use the Thonny IDE for the purpose of programming this kit and if you are a beginner and you’ll see why.
Inside the Thonny IDE, which is available for Mac OSX, Windows and Linux; We can configure our Eduponics Mini to work right out of the box. The IDE allows us to communicate through UART directly, upload code, run code, and manage existing files on the Eduponics Mini.
With the Thonny IDE, you can run, manage and execute files directly in an easy, convenient and fast way.
You can download Thonny IDE from here: Thonny IDE’s official website
Configuring Eduponics mini with Thonny IDE #
The first thing you should do is connect the Eduponics Mini to your PC/Mac using the USB Type-C cable.
Remember, the USB Type-C cable is the data cable we will use to write/read data from the Eduponics Mini kit while the DC power adapter is used to power the board, particularly the 12V pump.
Once we’ve connected the Eduponics Mini board – drivers should be installed automatically, if you have an old operating system you can install them manually using the instructions we’ve mentioned earlier.
Under Thonny -> Preferences you will find a tab called interpreter like this:
In the interpreter make sure to choose MicroPython (ESP32) because that’s the one we are using and in the port, you should see the USB Serial port, choose the one that is suitable to the Eduponics Mini device and not any other device that is connected to your system.
Press OK to save the settings.
Getting started with IoT – Hello world program #
Now when everything is ready – it’s time to run our first command to make sure everything is working.
In Python, we use the “print” command to print something into the terminal (or console if you are on windows) to run the hello world command – type the following into the putty window or your terminal after connecting to the USB UART using the “screen” command:
if you are using Thonny IDE, on the bottom of the IDE, once you’ve connected your ESP32 Eduponics kit successfully, you should notice something similar to:
“MicroPython v1.13 on 2020-09-02; ESP32 module with ESP32”.
Now every line of code you’ll write will be directly executed on the Eduponics mini ESP32 microcontroller.
Once you’ve typed the command and pressed “Enter” you should see “Hello world” on your screen! well done!
Command is executed on the ESP32 not on your machineOnce the “hello world” printing command was successfully executed, be aware that it was executed on the ESP32 Eduponics Mini board directly!
Your machine may or may not have Python3 installed but the code through Thonny is running on the development board directly which means we can continue to code more exciting things and explore all the features the Eduponics Mini prepared for us!
Installing micropython-eduponics Library #
In order to ease things up, we’ve created a special library MicroPython for the Eduponics Mini and the Eduponics Mini extension board.
The library can be found on our GitHub account: Micropython-Eduponics on GitHub
This library will allow us to use a different types of functions with ease without the need to drag external dependencies and libs to the ESP32 board. If you are planning on using the Arduino IDE environment, you can ignore the following steps. This Micropython library will help us getting started with IoT programming by providing all the libraries and code needed.
We will install the library through upip which is a MicroPython implementation of pip, a python package manager. In order to do that, we first have to connect to the WiFi, we can do this by creating a file called boot.py on our Eduponics Mini device inside Thonny IDE and adding the following lines:
import network import esp esp.osdebug(None) import gc gc.collect() ssid = 'WIFI_NAME' password = 'WIFI_PASSWORD' station = network.WLAN(network.STA_IF) station.active(True) station.connect(ssid, password) while station.isconnected() == False: pass print('Connected to WiFi successfully, IP: %s' % station.ifconfig())
We need to make sure to change WIFI_NAME and WIFI_PASSWORD to your Access point at home (WiFI credentials), and make sure that the WiFi is 2.4GhZ and not 5G as the ESP32 currently doesn’t support 5G wireless networks.
Once the ESP32 is successfully connected to the WiFi and received the IP address, we can write the following commands:
import upip upip.install("micropython-eduponics")
This will import upip and use the command upip.install() we can install the micropython-eduponics library. Now once everything is ready, we can import the Eduponics library and time and use the API to ease our programming experience and tasks!
Leave A Comment