Usage of each blocks - wandererinhk/IoT-extension-for-mBlock GitHub Wiki
Attach WiFi Module RX@ TX@
- Attach a Me Wifi module/ESP8266 chip to controller board
- To find out the pin numbers, refer to following:
- For mCore in particular,
- Port 1==> RX 12, TX 11 (HIGHLY RECOMMENDED)
- Port 2==> RX 10, TX 9 (HIGHLY RECOMMENDED)
- Port 3==> RX 17, TX 16
- Port 4==> RX 15, TX 14
- For Me Orion,
- Port 3==> RX 13, TX 12 (HIGHLY RECOMMENDED)
- Port 4==> RX 2, TX 8 (HIGHLY RECOMMENDED)
- Port 6==> RX 17, TX 16
- IMPORTANT: cannot use Port 1,2,5,7 and 8 on Me Orion!
- For Me Auriga,
- Port 6 ==> RX 69, TX 64
- Port 7 ==> RX 68, TX 63
- Port 8 ==> RX 67, TX 62
- Port 9 ==> RX 66, TX 61
- Port 10==> RX 65, TX 60
- IMPORTANT: cannot use Port 1-5 on Me Auriga!
- For MegaPi/Mega's analog pins,
- pin number = 54+(number)
- eg. A10 = 54+10 = 64
WiFi.write
- Write a line to Me Wifi module
- Can type-in AT commands directly, no need to add \r\n
- For AT-commands available, refers to online documentations
Connect AP|SSID |PW
- Connect to desired AP, will obtain IP automatically
- This block is deliberately designed to be a Boolean function
- Always use with "if" or "if-else" blocks to verify connection status
- This block can take up to 18 seconds for connection
- Will return true once connected within the period
- Timeout set to be 16 seconds, based on experiment
- Will return false if timeout after 16 seconds
- Timeout can due to:
- Incorrect SSID
- Incorrect Password
- AP is not activated
- Radio interference
Upload to thingspeak.com|API |Content
- IMPORTANT: do not update sensor values within this function!!
- Tends to cause overflow / fatal error
- Instead, pass the data through variables
- Upload a HTTP GET request to api.thingspeak.com
- This block is deliberately designed to be a Boolean function
- Always use with "if" or "if-else" blocks to verify upload results
- This block can take a few seconds for uploading data
- Will return true once successfully uploaded
- Timeout set to be 5 seconds
- Will return false if timeout after 5 seconds
- Fill-in your channel's API
- May get one under "API Key" tab after logged in thingspeak.com
- Format of "Content" shall be:
- field1={data}&field2={data}&{...}&field8={data}
- For uploading 1 field, "Content" would be,
- For 2 fields,
field1={data}&field2={data}
- User can use blocks from "Operators" to join strings together
- For free users of thingspeak.com, upload interval shall be >=30s
- The maximum number of field supported by thingspeak.com is 8
Trigger an event to maker.ifttt.com|Event name |API |Content
- Upload a HTTP GET request to maker.ifttt.com
- This block is deliberately designed to be a Boolean function
- Always use with "if" or "if-else" blocks to verify upload results
- This block can take a few seconds for uploading data
- Will return true once successfully uploaded
- Timeout set to be 5 seconds
- Will return false if timeout after 5 seconds
- Set the desire EventName in Maker Webhooks Applets
- Fill-in the API Key of your account
- Format of "Content" shall be:
value1={data}&value2={data}&value3={data}
- User can use blocks from "Operators" to join strings together
- If only want to trigger an event without any values, leave "Content" blank
- It could take a few seconds for the server to carry out the actions
- The maximum number of field supported by maker.ifttt.com is 3
Get Weather Info from OpenWeatherMap|API |City ID |Type
- WARNING! This block use a huge (600+ bytes) amount of local variables, preferably to use on Auriga/MegaPi/Mega only
- Get current weather data from openweathermap.org
- This block can take few seconds for downloading data
- Will return required content string once successfully downloaded
- Timeout set to be 5 seconds
- Will return false if timeout after 5 seconds
- Fill-in the API Key of your account
- CityID list
- "Type" can be:
- temp ==>in Kelvin (K), -273.15 to convert into Celsius
- pressure ==>in HPA
- humidity ==>in %RH
- visibility ==>in m