oddWires IoT-Bus Скачать руководство пользователя страница 6

iot-bus Documentation, Release latest

2

IoT-Bus Introduction

Содержание IoT-Bus

Страница 1: ...iot bus Documentation Release latest oddWires Mar 05 2019...

Страница 2: ......

Страница 3: ...uino 19 6 Getting Started with esp idf 21 7 Getting Started with Mozilla IoT 23 8 Getting Started with Micro Python 29 9 Getting Started with Moddable 31 10 Getting Started with MicroBlocks 33 11 Io 3...

Страница 4: ...IoT Bus LED Thing 97 31 IoT Bus LED Lamp Thing 99 32 IoT Bus Relay Thing 103 33 IoT Bus Relay Display Touch Thing 105 34 IoT Bus Window and Door Sensor Thing 111 35 IoT Bus DHT11 Thing 113 36 IoT Bus...

Страница 5: ...iot bus Documentation Release latest IoT Bus Introduction 1...

Страница 6: ...iot bus Documentation Release latest 2 IoT Bus Introduction...

Страница 7: ...d build on adaptable tested with many solutions already available There are no lock in costs and overall it provide a low cost solution for faster development of professional educational and hobbyist...

Страница 8: ...4 Touch TFT QVGA Display Available Solder able Prototype Board with Controller IOT Ready Relay and Motor Controller Multiple open platforms Supports C MicroPython and javascript At the heart of the sy...

Страница 9: ...Io Very small and breadboard friendly with option of male female or both stackable headers Includes a dual core 240 MHz ESP32 with WiFi and Bluetooth You can use the WiFi both in station device mode a...

Страница 10: ...ve JTAG debugging support You can use OpenOCD and GDB in combination to use it but our recommendation is to use PlatformIO PlatformIO has taken away all the hard work of configuring OpenOCD and GDB Yo...

Страница 11: ...ffering plug and play display output and touch sensing together with a 4 bit SD MMC SD Card We picked 2 4 over 2 8 as it has a crisper display at 320 x 240 res olution and its slightly smaller size he...

Страница 12: ...ver that en ables you to use the onboard ESP32 CAN controller You can connect the terminals to any required connection LoRa This IoT Bus mod ule uti lizes the Hope RFM95 to of fer low cost LoRa ra dio...

Страница 13: ...0 dBm power amplifier yields industry leading link budget making it optimal for any application requiring range or robustness LoRa also pro vides sig nif i cant ad van tages in both block ing and se l...

Страница 14: ...board driven by a single digital pin It is a 110V 10A maximum AC relay board in the IoT Bus form factor Motor This IoT Bus mod ule provides a motor controller It uses two TB6612FNG mo tor drivers cont...

Страница 15: ...y used in mobile devices and the Internet of Things applications 1 9 Frameworks Name Description Ar duino Arduino Wiring based Framework allows writing cross platform software to control devices attac...

Страница 16: ...iot bus Documentation Release latest 12 Chapter 1 IoT Bus Overview...

Страница 17: ...CHAPTER 2 IoT Bus Pinout 13...

Страница 18: ...iot bus Documentation Release latest Fig 1 IoT Bus Pinout 14 Chapter 2 IoT Bus Pinout...

Страница 19: ...programmer or a serious hobbyist then you will probably pick PlatformIO There are other environments that are just fine if you already use them like Eclipse or NetBeans But if you are investing your...

Страница 20: ...vers for it and a whole development infrastructure that has sprung up around it And Moddable is the company that just does javascript right We ll show you later in this section how to get started with...

Страница 21: ...board here 4 Git clone or download the IoT Bus examples from Github https github com iot bus iot bus examples platformio 5 Plug in IoT Bus Io Open the iot bus blink example and run Onboard LED should...

Страница 22: ...iot bus Documentation Release latest 18 Chapter 4 Getting Started with PlatformIO...

Страница 23: ...instructions 2 Install the Espressif32 platform package Start Arduino and open Preferences window Enter https dl espressif com dl package_esp32_index json into Additional Board Manager URLs field You...

Страница 24: ...iot bus Documentation Release latest 20 Chapter 5 Getting Started with Arduino...

Страница 25: ...e It s much easier using platformIO because it does all the hard work behind the scenes However it maybe useful to see the steps involved See Getting Started with Platformio for the easy way to use es...

Страница 26: ...iot bus Documentation Release latest 22 Chapter 6 Getting Started with esp idf...

Страница 27: ...e Setup If you didn t buy a Mozilla IoT get from oddWires which includes an SD Card flashed with the Mozilla IoT Gateway you will need to download gateway image as a zip file from here Expand it and f...

Страница 28: ...connected to that same network in order to continue setup If you re directly connected via ethernet you do not need to do this Next you ll be asked to choose a unique subdomain for your gateway which...

Страница 29: ...choose your own domain name if you don t want to use the tunneling service but you ll need to generate your own SSL certificate and configure DNS yourself This is the screen you will see You will then...

Страница 30: ...ay and will be ready to start adding things Note that the gateway s web interface is a Progressive Web App that you can add to home screen on your smartphone with Firefox Now you should see this scree...

Страница 31: ...ched adapters into pairing mode Follow the instructions for your individual device to pair it with the gateway this often involves pressing a button on the device while the gateway is in pairing mode...

Страница 32: ...iot bus Documentation Release latest 28 Chapter 7 Getting Started with Mozilla IoT...

Страница 33: ...load the firmware from this location For convenience this is a link to an ESP32 binary esp32 20180924 v1 9 4 575 g6ea6c7cc9 bin You will need esptool py available right here If you are putting MicroPy...

Страница 34: ...iot bus Documentation Release latest 30 Chapter 8 Getting Started with Micro Python...

Страница 35: ...CHAPTER 9 Getting Started with Moddable You can find details on Getting Started with Moddable here 31...

Страница 36: ...iot bus Documentation Release latest 32 Chapter 9 Getting Started with Moddable...

Страница 37: ...tions that require precision timing autonomous operation or physically embedding the processor into projects For example one might write a program to record acceleration data then embed the microcontr...

Страница 38: ...iot bus Documentation Release latest 34 Chapter 10 Getting Started with MicroBlocks...

Страница 39: ...access point mode It includes traditional Bluetooth as well as BLE 4 0 On board is a 3 3V regulator and a battery charging device that enables you to switch between using USB or battery power The batt...

Страница 40: ...SP32 ArduinoJson Io Proteus Arduino C JSON library for IoT Simple and efficient arduino Lora LoRa Arduino Sandeep Mistry s arduino LoRa library Arduino CAN CAN Bus Arduino Sandeep Mistry s Arduino CAN...

Страница 41: ...BSD No pcf8574 Driver for PCF8574 remote 8 bit I O expander for I2C bus MIT Yes hd44780 Universal driver for HD44780 LCD display BSD No pca9685 Driver for 16 channel 12 bit PWM PCA9685 BSD Yes ms5611...

Страница 42: ...ramework allows writing cross platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding interactive objects spaces or physical experiences...

Страница 43: ...iFi both in station device mode and access point mode It includes traditional Bluetooth as well as BLE 4 0 On board is a 3 3V regulator and a battery charging device that enables you to switch between...

Страница 44: ...he Proteus includes both 3 3V and 5V rails Both these rails are available whether powered by the USB or the battery as the 5V is derived from the lower voltage Buy it in the oddWires store 12 1 Pins U...

Страница 45: ...ports from esp open rtos 12 3 esp idf lib Components Component Description License Thread safety i2cdev I2C utilities MIT Yes ds1307 Driver for DS1307 RTC module BSD Yes ds3231 Driver for DS3231 high...

Страница 46: ...used in mobile devices and the Internet of Things applications 12 6 Frameworks Name Description Ar duino Arduino Wiring based Framework allows writing cross platform software to control devices attac...

Страница 47: ...r JTAG board is based on the FT232H and it enables comprehensive JTAG debugging support You can use OpenOCD and GDB in combination to use it but our recommendation is to use PlatformIO PlatformIO has...

Страница 48: ...debug_tool iot bus jtag 13 2 Pins Used IOT Bus JTAG Pin Board JTAG Pin 3V3 Positive Supply Voltage Power supply for JTAG interface drivers GND GND Digital Ground 12 TDI Test Data In pin 14 TMS Test M...

Страница 49: ...amework allows writing cross platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding interactive objects spaces or physical experiences E...

Страница 50: ...iot bus Documentation Release latest 46 Chapter 13 JTAG...

Страница 51: ...output and touch sensing together with a 4 bit SDMMC SD Card We picked 2 4 over 2 8 as it has a crisper dis play at 320 x 240 resolution and its slightly smaller size helps in IoT applications Design...

Страница 52: ...rd 14 CLK SD Card 15 CMD SD 16 SS Touch Screen 17 IRQ Touch Screen 18 SCK TFT 19 MISO TFT 23 MOSI TFT 27 DC TFT 33 Backlight TFT you will not see anything if you do not turn on the backlight EN RESET...

Страница 53: ...y has been forked to setup defaults XPT2046_Touchscreen Arduino Fork of Paul Stoffgren s XPT2046_Touchscreen library ESP32_TFT_library esp idf loboris TFT library for ESP32 14 3 Schematic Click image...

Страница 54: ...iot bus Documentation Release latest 50 Chapter 14 2 4 QVGA Touch Display...

Страница 55: ...CHAPTER 15 Motor Buy it in the oddWires store 15 1 Pins Used IOT Bus Pin Description 21 SDA 22 SCL 3V3 Power GND Ground 51...

Страница 56: ...They provide wireless communica tions and Wi Fi chips which are widely used in mobile devices and the Internet of Things applications 15 5 Frameworks Name Description Ar duino Arduino Wiring based Fr...

Страница 57: ...to isolated relay board driven by a single digital pin It is a 110V 10A maximum AC relay board in the IoT Bus form factor Buy it in the oddWires store 16 1 Pins Used IOT Bus Pin Description 17 Relay 1...

Страница 58: ...ch are widely used in mobile devices and the Internet of Things applications 16 4 Frameworks Name Description Ar duino Arduino Wiring based Framework allows writing cross platform software to control...

Страница 59: ...CHAPTER 17 CAN Bus Buy it in the oddWires store 17 1 Pins Used IOT Bus Pin Description 4 CAN Bus RXD 5 CAN Bus TXD Note CAN Bus cannot be used at the same time as LoRa 55...

Страница 60: ...fabless semiconductor company They provide wireless communica tions and Wi Fi chips which are widely used in mobile devices and the Internet of Things applications 17 5 Frameworks Name Description Ar...

Страница 61: ...over 148dBm using a low cost crystal and bill of materials The high sensitivity combined with the integrated 20 dBm power amplifier yields industry leading link budget making it optimal for any appli...

Страница 62: ...Fully integrated synthesizer with a resolution of 61 Hz FSK GFSK MSK GMSK LoRa and OOK modulation Built in bit synchronizer for clock recovery Preamble detection 127 dB Dynamic Range RSSI Automatic RF...

Страница 63: ...the same time as CAN Bus 18 2 Libraries Name Framework Description arduino Lora Arduino Sandeep Mistry s arduino LoRa library 18 3 Schematic Click image to enlarge 18 4 Platforms Name Description Esp...

Страница 64: ...amework allows writing cross platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding interactive objects spaces or physical experiences E...

Страница 65: ...at are described in this section are a subset of the examples in the repository If you run through these examples you ll discover how to use each of them Blink Get started with the ubiquitous Blink an...

Страница 66: ...iot bus Documentation Release latest 62 Chapter 19 IoT Bus Examples Index...

Страница 67: ...s line sets the GPIO pin into output mode pinMode LEDPin OUTPUT This line turns on the LED digitalWrite LEDPin HIGH This line turns off the LED digitalWrite LEDPin LOW This line creates 1 second delay...

Страница 68: ...nction runs over and over again forever void loop digitalWrite LEDPin HIGH turn the LED on HIGH is the voltage level delay 1000 wait for a second digitalWrite LEDPin LOW turn the LED off by making the...

Страница 69: ...char password Enter the ssid and password of the local WiFi network you want to connect to Serial begin 115200 WiFi begin ssid password while WiFi status WL_CONNECTED delay 1000 Serial println Connect...

Страница 70: ...Start the web server The full example include WiFi h include AsyncTCP h include ESPAsyncWebServer h const char ssid const char password AsyncWebServer server 80 void setup Serial begin 115200 WiFi beg...

Страница 71: ...a very similar way include touchscreen library include XPT2046_Touchscreen h Call up the TFT driver library include TFT_eSPI h Hardware specific library include SPI h Invoke custom TFT driver library...

Страница 72: ...ft init These lines initialize and calibrate the touchscreen and display Set the TFT and touch screen to landscape orientation tft setRotation 1 ts setRotation 1 Rotation 0 and 2 are portrait and 1 an...

Страница 73: ...uchscreen h Call up the TFT driver library include TFT_eSPI h Hardware specific library include SPI h Invoke custom TFT driver library TFT_eSPI tft TFT_eSPI Invoke custom library These pins are define...

Страница 74: ...n tft setCursor ts getWidth swatchWidth 1 5 3 2 x y font tft setTextColor TFT_WHITE tft print Clear tft drawRect 0 0 ts getWidth 1 swatchHeight TFT_WHITE Plot the current colour in the screen clear bo...

Страница 75: ...ght ts getWidth ts getHeight 1 color Serial println clear screen to current color else color colors p x swatchWidth Update the current color in the clear box tft fillRect ts getWidth swatchWidth 20 12...

Страница 76: ...iot bus Documentation Release latest 72 Chapter 22 IoT Bus Touch Draw Example...

Страница 77: ...lude arduino h define RelayPin 17 the setup function runs once when you press reset or power the board void setup initialize digital pin Relay_BUILTIN as an output pinMode RelayPin OUTPUT Serial begin...

Страница 78: ...iot bus Documentation Release latest 74 Chapter 23 IoT Bus Relay Example...

Страница 79: ...up Serial begin 115200 start the CAN bus at 1000 kbps if CAN begin 1000E3 Serial println Starting CAN failed while 1 Include the CAN Bus library and start it up at 1Mbps CAN beginPacket 0x12 CAN write...

Страница 80: ...he CAN bus at 1000 kbps if CAN begin 1000E3 Serial println Starting CAN failed while 1 void loop send packet id is 11 bits packet can contain up to 8 bytes of data Serial print Sending packet CAN begi...

Страница 81: ...eived See if we have received a packet and get its size if CAN packetExtended Serial print extended Identify an extended packet if CAN packetRtr Remote transmission request packet contains no data Ser...

Страница 82: ...tarting CAN failed while 1 void loop try to parse packet int packetSize CAN parsePacket if packetSize received a packet Serial print Received if CAN packetExtended Serial print extended if CAN packetR...

Страница 83: ...e SS 5 define RESET 17 int counter 0 void setup LoRa setPins SS RESET DIO0 These lines include the libraries required and define the DIO0 SS and RESET pins required to use the IoT BUs LoRa board if Lo...

Страница 84: ...if LoRa begin 915E6 Serial println Starting LoRa failed while 1 void loop Serial print Sending packet Serial println counter send packet LoRa beginPacket LoRa print hello LoRa print counter LoRa endPa...

Страница 85: ...char LoRa read These lines will read the packet until there s no more data Serial println LoRa packetRssi This line will print out the signal strength indicator include SPI h include LoRa h define DIO...

Страница 86: ...t bus Documentation Release latest continued from previous page Serial print char LoRa read print RSSI of packet Serial print with RSSI Serial println LoRa packetRssi 82 Chapter 25 IoT Bus LoRa Exampl...

Страница 87: ...ary libraries and create a motor controller at address 0x5F You can change the solder jumpers on the board for another address between 0x40 and 0x5F Connect a stepper motor with 200 steps per revoluti...

Страница 88: ...afruit_MotorShield AFMS Adafruit_MotorShield 0x5F Connect a stepper motor with 200 steps per revolution 1 8 degree to motor port 2 M3 and M4 Adafruit_StepperMotor myMotor AFMS getStepper 200 1 void se...

Страница 89: ...d Type if cardType CARD_MMC Serial println MMC else if cardType CARD_SD Serial println SDSC else if cardType CARD_SDHC Serial println SDHC else Serial println UNKNOWN uint64_t cardSize SD_MMC cardSize...

Страница 90: ...MMC include FS h include SD_MMC h include driver gpio h include SPI h void listDir fs FS fs const char dirname uint8_t levels Serial printf Listing directory s n dirname File root fs open dirname if r...

Страница 91: ...ile while file available Serial write file read void writeFile fs FS fs const char path const char message Serial printf Writing file s n path File file fs open path FILE_WRITE if file Serial println...

Страница 92: ...void testFileIO fs FS fs const char path File file fs open path static uint8_t buf 512 size_t len 0 uint32_t start millis uint32_t end start if file len file size size_t flen len start millis while l...

Страница 93: ...e if cardType CARD_MMC Serial println MMC else if cardType CARD_SD Serial println SDSC else if cardType CARD_SDHC Serial println SDHC else Serial println UNKNOWN uint64_t cardSize SD_MMC cardSize 1024...

Страница 94: ...iot bus Documentation Release latest 90 Chapter 27 IoT Bus SD_MMC Card Example...

Страница 95: ...s iot bus mozilla iot examples arduino Examples in ino format You will need to install required libraries separately In each example you will have to enter your ssid and password within the main cpp f...

Страница 96: ...PI Of course if you are using other libraries for sensors or your own you can include them here and PlatformIO will locate and install them LED Thing This example creates a Thing that enables the buil...

Страница 97: ...ouch switch Thing that triggers when one of the capacitive touch pins on the ESP32 are touched It sets the on board LED on triggering and updates the mozilla iot interface appropriately Connect a wire...

Страница 98: ...iot bus Documentation Release latest 94 Chapter 28 IoT Bus Mozilla IoT Examples...

Страница 99: ...es a touch sensor to detect input and turn on a LED int ledPin 5 choose the pin for the LED int touchPin 4 choose the input pin T0 is the same as GPIO4 WebThingAdapter adapter const char sensorTypes b...

Страница 100: ...e MOZ IoT thing adapter new WebThingAdapter adapter WiFi localIP touch addProperty touched adapter addDevice touch adapter begin pinMode ledPin OUTPUT declare LED as output void loop int val touchRead...

Страница 101: ...file You can obtain one at http mozilla org MPL 2 0 include Arduino h include Thing h include WebThingAdapter h TODO Hardcode your wifi credentials here and keep it private const char ssid const char...

Страница 102: ...rite ledPin HIGH active low led Serial println Serial print Connected to Serial println ssid Serial print IP address Serial println WiFi localIP adapter new WebThingAdapter w25 WiFi localIP led addPro...

Страница 103: ...ributed with this file You can obtain one at http mozilla org MPL 2 0 include Arduino h include Thing h include WebThingAdapter h define MIN a b a b a b const char ssid const char password if defined...

Страница 104: ...d setup void pinMode lampPin OUTPUT digitalWrite lampPin LOW initially off Setup timer and attach timer to a led pin ledcSetup LEDC_CHANNEL_0 LEDC_BASE_FREQ LEDC_TIMER_13_BIT ledcAttachPin lampPin LED...

Страница 105: ...oop void adapter update if lampOn getValue boolean int level map lampLevel getValue number 0 100 0 255 Serial println lampLevel getValue number ledcAnalogWrite LEDC_CHANNEL_0 level analogWrite lampPin...

Страница 106: ...iot bus Documentation Release latest 102 Chapter 31 IoT Bus LED Lamp Thing...

Страница 107: ...elayPin 17 IoT Bus relay WebThingAdapter adapter const char relayTypes SmartPlug nullptr ThingDevice relay relay IoT Bus Relay relayTypes ThingProperty relayOn on BOOLEAN OnOffProperty bool lastOn fal...

Страница 108: ...P Initialize MOZ IoT thing adapter new WebThingAdapter adapter WiFi localIP relay addProperty relayOn adapter addDevice relay adapter begin Serial println HTTP server started Serial print http Serial...

Страница 109: ...t be on GPIO17 and PENIRQ not used TFT OK either way Graphics and Touch include TFT_eSPI h include XPT2046_Touchscreen h We use modified version that maps from raw to pixel and matches screen orientat...

Страница 110: ...ThingDevice relay Relay IoT Bus Relay relayTypes ThingProperty relayOn on BOOLEAN OnOffProperty remember last state bool lastOn false the setup function runs once when you press reset or power the bo...

Страница 111: ...alue value void loop bool on relayOn getValue boolean if touched true on on invert status lastOn on invert status value boolean on relayOn setValue value delay 300 avoid touch bounce update status ada...

Страница 112: ...1 bgColor sockets tft fillRoundRect LEFT_SOCKET_X LEFT_SOCKET_Y SOCKET_WIDTH SOCKET_HEIGHT SOCKET_RADIUS socketColor tft fillRoundRect RIGHT_SOCKET_X RIGHT_SOCKET_Y SOCKET_WIDTH SOCKET_HEIGHT SOCKET_R...

Страница 113: ...H bgColor F tft fillRect TEXT_2_X TEXT_2_Y STROKE_WIDTH TEXT_HEIGHT textColor tft fillRect TEXT_2_X TEXT_2_Y TEXT_WIDTH STROKE_WIDTH textColor tft fillRect TEXT_2_X TEXT_2_Y TEXT_HEIGHT 2 TEXT_WIDTH S...

Страница 114: ...iot bus Documentation Release latest 110 Chapter 33 IoT Bus Relay Display Touch Thing...

Страница 115: ...ED when open int ledPin 5 choose the pin for the LED int sensorPin 4 choose the input pin we ll use a pullup on this pin to keep high Connect one end of the door switch to this pin Connect the other e...

Страница 116: ...ebThingAdapter adapter WiFi localIP sensor addProperty openProperty adapter addDevice sensor adapter begin pinMode sensorPin INPUT_PULLUP pinMode ledPin OUTPUT declare LED as output void loop int val...

Страница 117: ...CHAPTER 35 IoT Bus DHT11 Thing include arduino h continues on next page 113...

Страница 118: ...emperature The temperature from x to y NUMBER LevelProperty Temperature F false ThingProperty humidity humidity The humidity from 0 to 100 NUMBER LevelProperty Humidity percent false ThingPropertyValu...

Страница 119: ...fortStatus Comfort_OK break case Comfort_TooHot comfortStatus Comfort_TooHot break case Comfort_TooCold comfortStatus Comfort_TooCold break case Comfort_TooDry comfortStatus Comfort_TooDry break case...

Страница 120: ...eFont FreeSans18pt7b display setRotation 1 display setTextColor color display setTextSize scale display setCursor x y display println str void setup Serial begin 115200 dht setup dhtPin DHTesp DHT11 T...

Страница 121: ...F String newValues humidity if current last displayString last ILI9341_BLACK clear old text by writing it black displayString current ILI9341_WHITE write the new value reading number dht toFahrenheit...

Страница 122: ...iot bus Documentation Release latest 118 Chapter 35 IoT Bus DHT11 Thing...

Страница 123: ...CHAPTER 36 IoT Bus HC SR04 Thing Arduino framework include arduino h MOZ IoT continues on next page 119...

Страница 124: ...int trigPin 2 Trigger int echoPin 4 Echo long duration cm inches displayString helper function to draw text on the TFT display const int textHeight 18 const int textWidth 18 const int width 320 const...

Страница 125: ...tln Wait for connection while WiFi status WL_CONNECTED delay 500 Serial print Serial println Serial print Connected to Serial println ssid Serial print IP address Serial println WiFi localIP Initializ...

Страница 126: ...2 74 Divide by 74 or multiply by 0 0135 Uncomment to display on serial monitor Serial print inches Serial print in Serial print cm Serial print cm Serial println if cm 400 cm 2 current Out of range e...

Страница 127: ...CHAPTER 37 IoT Bus HC SR501 PIR Thing include Arduino h Simple motion sensor example using HC S501 continues on next page 123...

Страница 128: ...erty ThingPropertyValue sensorValue void setup Serial begin 115200 Use serial monitor for debugging Start WiFi WiFi mode WIFI_STA WiFi begin ssid password Serial println Wait for connection while WiFi...

Страница 129: ...ensorValue boolean true digitalWrite ledPin HIGH else if sensorOn getValue boolean true Turned off Serial println Motion ended Update on the output change not state sensorValue boolean false digitalWr...

Страница 130: ...iot bus Documentation Release latest 126 Chapter 37 IoT Bus HC SR501 PIR Thing...

Страница 131: ...____ WiFi ssid and password const char ssid const char password simple window style class used for the response box and buttons enum alignment LEFT RIGHT MIDDLE class Button public Button TFT_eSPI _tf...

Страница 132: ...eight TFT_WHITE tft fillRect x width 5 y 5 height TFT_DARKGREY tft drawFastVLine x width 1 y height TFT_WHITE draw the text tft setTextSize 4 tft setTextColor color tft println text bool hit TS_Point...

Страница 133: ...FT_LIGHTBLUE TFT_LIGHTSALMON TFT_LIGHTGREY TFT_LIGHTGREEN TFT_LIGHTBLUE enum buttonType NUM CLEAR EQUALS DIVIDE MULTIPLY ADD SUBTRACT uint8_t buttonTypes 4 4 NUM NUM NUM DIVIDE NUM NUM NUM MULTIPLY NU...

Страница 134: ...80 define buttonHeight 60 define buttonWidth 60 resultBox new Button tft we are using the touchscreen to getwidth as we know it changes with orientation need to check tft resultBox setRect 0 0 ts getW...

Страница 135: ...r Accumulator 0 function button getText break Hittest for all buttons Button hitTest TS_Point p for int i 0 i BUTTONCOUNT i if buttons i hit p Serial println buttons i getText handleButton buttons i r...

Страница 136: ...y IoT Bus Calculator textDisplayTypes ThingProperty accumulatorProperty Accumulator NUMBER nullptr ThingProperty num1Property Number 1 NUMBER nullptr ThingProperty num2Property Number 2 NUMBER nullptr...

Страница 137: ...m1Property textDisplay addProperty num2Property functionProperty setValue value textDisplay addProperty functionProperty adapter addDevice textDisplay adapter begin Create and draw calculator calculat...

Страница 138: ...iot bus Documentation Release latest 134 Chapter 38 IoT Bus Calculator Thing...

Страница 139: ...uch switch thing which uses the capacitive switch capability of the IoT Bus ESP32 processor and the LED lamp We will see how to get the working on their own and then use the Mozilla IoT Rules engine t...

Страница 140: ...iot bus Documentation Release latest 136 Chapter 39 IoT Bus Mozilla IoT Tutorials...

Страница 141: ...la IoT gateway on a Raspberry PI as described here include Arduino h include Thing h include WebThingAdapter h These lines include the Arduino framework and the Mozilla IoT device and adapter librarie...

Страница 142: ...nd exposes its capabilities led addProperty ledOn adapter addDevice led adapter begin These three lines add the ledOn property to the led then add the device to the adapter and then start the adapter...

Страница 143: ...have it reflected through the gateway We get that current value of the property ledOn And we use it to set the value of the LED if it has changed we print the changed value to the serial monitor So no...

Страница 144: ...Source Code Form is subject to the terms of the Mozilla Public License v 2 0 If a copy of the MPL was not distributed with this file You can obtain one at http mozilla org MPL 2 0 include Arduino h in...

Страница 145: ...n blink LOW HIGH active low led blink blink digitalWrite ledPin HIGH active low led Serial println Serial print Connected to Serial println ssid Serial print IP address Serial println WiFi localIP ada...

Страница 146: ...iot bus Documentation Release latest 142 Chapter 40 LED Thing Tutorial...

Страница 147: ...o trip You will need to have installed the Mozilla IoT gateway on a Raspberry PI as described here include Arduino h include Thing h include WebThingAdapter h These lines include the Arduino framework...

Страница 148: ...t list available at this location ThingProperty touched Touched BOOLEAN BooleanProperty This defines a property Touched which has a property type of BooleanProperty Again this is a predefined property...

Страница 149: ...ld also change this to reflect a multi level value rather than a binary value if we wished The ED and sensorValue are set to reflect the reading of T0 and the adapter is updated Note T0 is the same as...

Страница 150: ...sing ESP32 capacitive touch input This example code is in the public domain TODO Hard code your WiFi credentials here and keep it private const char ssid const char password Uses a touch sensor to det...

Страница 151: ...nt IP address Serial println WiFi localIP Initialize MOZ IoT thing adapter new WebThingAdapter adapter WiFi localIP touch addProperty touched adapter addDevice touch adapter begin pinMode ledPin OUTPU...

Страница 152: ...iot bus Documentation Release latest 148 Chapter 41 Touch Switch Thing Tutorial...

Страница 153: ...hing the Touch Thing to control the other the lED Thing What we want to do is have the LED Thing on when we hold the Touch wire on the other Thing and off when when we release it So we are going to cr...

Страница 154: ...he add button on the bottom right and you ll see this You should be able to see the devices LED and IoT Bus Touch Input If you can t you ll need to go back and add them according to the two previous t...

Страница 155: ...the input box The select the Touched property from the choices given when you select the bottom right hand corner of the rule icon In a similar fashion drag the LED icon to thr right output box and s...

Страница 156: ...bus Documentation Release latest If you step back out of rule editing the rule should look like this In a similar fashion add the second rule for not touched LED off 152 Chapter 42 Mozilla Rules Engi...

Страница 157: ...bus Documentation Release latest Once you have done that you should see the finished result Now when you touch the wire on one Thing the status is reflected on the other Thing by the on board LED Easy...

Страница 158: ...iot bus Documentation Release latest 154 Chapter 42 Mozilla Rules Engine...

Страница 159: ...s platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding interactive objects spaces or physical experiences 43 2 ESP IDF Espressif IoT D...

Страница 160: ...iot bus Documentation Release latest 156 Chapter 43 Frameworks...

Страница 161: ...CHAPTER 44 Platforms 44 1 Espressif32 ESP WROOM32 WiFi Bluetooth Combo Module 157...

Страница 162: ...ications aimed at makers hardware engineers software engineers and solution provides ESP32 is a single chip 2 4 GHz Wi Fi and Bluetooth combo chip designed with TSMC ultra low power 40 nm technology I...

Страница 163: ...up to 150 Mbps 802 11 e QoS for wireless multimedia technology WMM PS UAPSD MPDU and A MSDU aggregation Block ACK Fragmentation and de fragmentation Automatic Beacon monitoring scanning 802 11 i secu...

Страница 164: ...based profile supported SPP Like GATT based profile BLE Beacon A2DP AVRCP SPP HSP HFP RFCOMM CVSD and SBC for audio codec Bluetooth Piconet and Scatternet Clocks and Timers Internal 8 MHz oscillator w...

Страница 165: ...Ultra low power analog pre amplifier Security IEEE 802 11 standard security features all supported including WFA WPA WPA2 and WAPI Secure boot Flash encryption 1024 bit OTP up to 768 bit for customer...

Отзывы: