Display temperature and Humidity on an OLED display This basic example teaches you how to create a circuit that uses two Grove modules and requires no soldering. The MKR board you choose may be anyone of the MKR family because the connection is managed through the MKR Connector Carrier . Hardware Required Arduino MKR family board Arduino MKR Connector Carrier Grove DHT Module Grove OLED 0.96" Circuit The connection to the Carrier board requires two standard Grove cables. The DHT humidity and temperature sensor goes to the D0 connector. The OLED screen is connected to the TWI connector. ](/en/uploads/Tutorial/MKRConnectorCarrier.jpg)[ We did not put a MKR board on the Carrier , but it is required to get the circuit to work, as specified in the bill of materials. The DHT module uses a specific pin to communicate with the MKR board and it is mapped on D0. This happens because the Grove standard for digital connections follows this rule: PinFunctrionNotespin1DnPrimary digital i/opin2Dn+1Secondary digital i/opin3VCCPower to module 5V/3.3Vpin4GNDGround and the module sends SIG on pin 1 that is mapped on the primary digital I/O. In the picture, the OLED module is shown from component side to let you see the Grove connector. It goes into the TWI male on the MKR Connector Carrier that follows this pin mapping: PinFunctrionNotespin1SCLI2C Clockpin2SDAI2C Datapin3VCCPower to module 5V/3.3Vpin4GNDGround Code To drive the modules you need to load four separate libraries: #include #include #include #include The DHT module is mapped on D0 when the object dht is instantiated: DHT dht(0, DHT22); The rest of the code is straightforward and keeps reading the hum and temp values to be printed on the OLED screen. Here is the complete sketch See also Getting started with MKR Connector Carrier Last revision 2018/08/08 by SM
Getting Started with the MKR Connector Carrier The MKR Connector Carrier allows any MKR board to use the range of modules and devices that use the Grove Connector , developer by Seeed Studio and now a de facto standard for solderless connection of analog and digital modules. PLEASE NOTE: a limited number of boards have a wrong labeling on the solder side. Please refer to the current image for the correct labelling. The component side labels are correct on all the boards. Please refer to them for your connections. Power supply All the I/Os are supplied at 5V and the carrier provides the proper 5V to 3.3V level shifting. The board has a buck converter that can be supplied with an external voltage from 7V to 16V connected to the VIN of the screw terminal block. The buck converter supplies the MKR board that provides the 5V and the 3.3V output that can also be found on the screw terminal blocks. Modules and cables The Grove modules have a standard four pins connector and usually the cable that comes with them has four standard colors: pin 1 - Yellow (for example, SCL on I2C Grove Connectors) pin 2 - White (for example, SDA on I2C Grove Connectors) pin 3 - Red - VCC on all Grove Connectors pin 4 - Black - GND on all Grove Connectors A0-A6 Analog input An Grove Analog connector consists of the standard four lines coming into the Grove plug. The two signal lines are generically called A0 and A1. Most modules only use A0. Often base units will have the first connector called A0 and the second called A1 and they will be wired A0/A1 and then A1/A2, etc. Pin Function Notes pin1 An Primary analog input pin2 An+1 Secondary analog input pin3 VCC Power to module 5V/3.3V pin4 GND Ground Input only (analog or digital) with a maximum allowed voltage of 5V. The 5V to supplied the sensor is provided by the board . The last connector labeled A5 A6 is a connector that wires two analog inputs into a single connector according to the grove connector specifications. If a single input has to be used the wired one is A5. D0-D6 Digital input output A digital Grove connector consists of the standard four lines coming into the Grove plug. The two signal lines are generically called D0 and D1. Most modules only use D0, but some do (like the LED Bar Grove display) use both. Often base units will have the first connector called D0 and the second called D1 and they will be wired D0/D1 and then D1/D2, etc. Pin Function Notes pin1 Dn Primary digital I/O pin2 Dn+1 Secondary digital I/O pin3 VCC Power to module 5V/3.3V pin4 GND Ground I/O digital with a maximum allowed voltage of 5V. The 5V to supplied the sensor is provided by the board . The last connector labeled D5 D6 is a connector that wires two digital I/O into a single connector according to the grove connector specifications. If a single I/O has to be used the wired one is D5. Serial The Serial connector on the board is wired to the MKR board according to the grove connector specifications. The Grove UART module is a specialized version of a Grove Digital Module. It uses both Pin 1 and Pin 2 for the serial input and transmit. The Grove UART plug is labeled from the base unit point of view. In other words, Pin 1 is the RX line (which the base unit uses to receive data, so it is an input) where Pin 2 is the TX line (which the base unit uses to transmit data to the Grove module). Pin Function Notes pin1 RX Serial receive pin2 TX Serial transmit pin3 VCC Power to module 5V/3.3V pin4 GND Ground TWI - I2C The TWI connector on the board is wired to the MKR board according to the grove connector specifications. There are many types of I2C Grove sensors available. Most are 5V/3.3V devices, but there are a few that are only 3.3V or 5.0V. You need to check the specifications. The Grove I2C connector has the standard layout. Pin 1 is the SCL signal and Pin 2 is the SDA signal. Power and Ground are the same as the other connectors. This is another special version of the Grove Digital Connector. In fact, often the I2C bus on a controller (like the ESP8266, Raspberry Pi and the Arduino) just uses Digital I/O pins to implement the I2C bus. The pins on the Raspberry Pi and Arduino are special with hardware support for the I2C bus. Pin Function Notes pin1 SCL I2C Clock pin2 SDA I2C Data pin3 VCC Power to module 5V/3.3V pin4 GND Ground See also Show humidity and temperature on an OLED screen The text of the Arduino getting started guide is licensed under a Creative Commons Attribution-ShareAlike 3.0 License . Code samples in the guide are released into the public domain.
GSM Web Server This sketch turns the Arduino board with the GSM shield and a data enabled SIM card into a web server. When the board receives a request from a connected client, it sends back the value of analog inputs 0-5. Not all network operators allow incoming data requests from outside their network. This means you can create a web server with the GSM shield, but you may not be able to connect to it from the public internet; only from another data enabled device from the same provider on the same network. You should check with your provider to see what specific policies they have in place regarding incoming data connections. Hardware Required Arduino Board Arduino + Telefonica GSM/GPRS Shield SIM card enabled for Data (optional) 6 potentiometers or other analog inputs attached to A0-A5 Circuit image of the Arduino GSM Shield on top of an Arduino board Optional analog sensors like photoresistors, potentiometers and such may be connected, as explained elsewhere in our tutorials, to pins A0 - A5 Code First, import the GSM library #include SIM cards may have a PIN number that enables their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank : #define PINNUMBER "" Define a number of constants that contain information about the GPRS network you're going to connect to. You'll need the Access Point Name (APN), login, and password. To obtain this information, contact your network provider for the most up to date information. This page has some information about various carrier settings, but it may not be current. Initialize instances of the classes you're going to use. You're going to need the GSM, GPRS, and GSMServer classes. When you instantiate the GSMServer class, you'll need to tell it which port to listen for incoming connections. Port 80 is the default port for HTTP requests. In setup , open a serial connection to the computer. After opening the connection, send a message indicating the sketch has started. Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network : Connect to the network by calling gsmAccess.begin() . It takes the SIM card's PIN as an argument. You'll also connect to the GPRS network using gprs.attachGPRS() . This requires the APN, login, and password you declared earlier. By placing this inside a while() loop, you can continually check the status of the connection and wait for them to both become true before proceeding. When the modem does connect and has attached itself to the GPRS network, gsmAccess() will return GSM_READY . Use this as a flag to set the notConnected variable to true or false . Once connected, the remainder of setup will run. Start the server using server.begin() . You can request the server's IP address with grps.getIPAddress() and end the setup. In loop , create an instance of GSMClient and check if there are any active connections While the client is connected, and there is data waiting to be read, begin to read the request. Read through the available bytes until a newline character has been received. In this instance, you won't actually do anything with the request, it's assumed that it is a HTTP request, and you'll serve up a web page. Once the request has been read, start to send a standard HTTP response header with client.print() and client.println() . Read through the analog inputs and send the values to the client. Send a closing tag for the webpage, and stop the client connection before closing the loop . Once your code is uploaded, open the serial monitor. Once the IP address is printed to the serial monitor, enter it into a web browser. You should see a webpage that reports the analog input values on each the Arduino's six inputs. if you cannot connect to the IP address, make sure your network operator enables incoming traffic. The complete sketch is below. See Also GPRS Constructor attachGPRS () GSMServer Constructor ready () beginWrite () write () endWrite () read () available () stop () Arduino GSM Shield - Complete product description. Getting started with the GSM Shield - Get everything set up in minutes. GSM library - Your reference for the GSM Library. GSMExamplesMakeVoiceCall - How to make a voice call with mic and speaker. GSMExamplesReceiveVoiceCall - The call is received and connected, the number that is calling is shown on serial monitor and then the call is hung up. GSMExamplesReceiveSMS - How to receive an SMS message. GSMExamplesSendSMS - How to send an SMS entering number and text through the serial monitor. GSMExamplesWebClient - Connect to the Arduino.cc home and print the contents on the serial monitor window. GSMToolsTestGPRS - Tries to access the internet over GPRS with supplied APN and credentials. Last revision 2018/08/23 by SM
GSM Web Client This sketch connects an Arduino board to the Arduino homepage, http://arduino.cc , through the GSM shield. It then prints the content of the page through the serial monitor of the Arduino Software (IDE). Hardware Required Arduino Board Arduino + Telefonica GSM/GPRS Shield SIM card enable for Data Circuit image of the Arduino GSM Shield on top of an Arduino board Code First, import the GSM library #include SIM cards may have a PIN number that enables their functionality. Define the PIN for your SIM. If your SIM has no PIN, you can leave it blank : #define PINNUMBER "" Define a number of constants that contain information about the GPRS network you're going to connect to. You'll need the Access Point Name (APN), login, and password. To obtain this information, contact your network provider for the most up to date information. This page has some information about various carrier settings, but it may not be current. Initialize instances of the classes you're going to use. You're going to need the GSM, GPRS, and GSMClient classes. Create some variables to hold the server, path, and port you wish to connect to. In setup , open a serial connection to the computer. After opening the connection, send a message indicating the sketch has started. Create a local variable to track the connection status. You'll use this to keep the sketch from starting until the SIM is connected to the network : Connect to the network by calling gsmAccess.begin() . It takes the SIM card's PIN as an argument. You'll also connect to the GPRS network using gprs.attachGPRS() . This requires the APN, login, and password you declared earlier. By placing this inside a while() loop, you can continually check the status of the connection and wait for them to both become true before proceeding. When the modem does connect and has attached itself to the GPRS network, gsmAccess() will return GSM_READY . Use this as a flag to set the notConnected variable to true or false . Once connected, the remainder of setup will run. Attempt to connect to the server using client.connect() . connect() requires two arguments, the server and port. Once connected to the server, make a HTTP request by calling client.print() . A typical web request looks like "GET pathname HTTP/1.0". print will send the message, just as a browser would. If the connection to the server failed, make a note of it in the serial monitor, and close up setup . Inside loop , check to see if there are bytes returned from the server. If so, read them and print them to the serial monitor. If the server disconnects, which it will typically do once it has completed the HTTP request, stop the client locally and close the loop . Once your code is uploaded, open the serial monitor. You should see the HTML of http://arduino.cc print out on screen when it is received. It will takes about one minute, so don't worry if you haven't a feedback immediately! The complete sketch is below. See Also GPRS Constructor attachGPRS () GSMClient Constructor ready () connect () beginWrite () write () endWrite () connected () read () available () peek () flush () stop () Arduino GSM Shield - Complete product description. Getting started with the GSM Shield - Get everything set up in minutes. GSM library - Your reference for the GSM Library. GSMExamplesMakeVoiceCall - How to make a voice call with mic and speaker. GSMExamplesReceiveVoiceCall - The call is received and connected, the number that is calling is shown on serial monitor and then the call is hung up. GSMExamplesReceiveSMS - How to receive an SMS message. GSMExamplesSendSMS - How to send an SMS entering number and text through the serial monitor. GSMExamplesWebServer - A web server that when gets a request from a client sends back the value read on Analog inputs. GSMToolsTestGPRS - Tries to access the internet over GPRS with supplied APN and credentials. Last revision 2018/08/23 by SM