8,367
edits
Changes
→Connect to Network via GSM
* '''OrangePi 2G-IOT Linux distribution of GSM online'''
Currently, the official OrangePi 2G-IOT Linux distribution supports Ubuntu, Debian and Raspbian, these new versions already support GSM Internet function, developers please go to the official website:(http://www.orangepi.cn/downloadresourcescn/)<br>
Download the latest, Linux, Release Mirror.Before using the GSM Internet function, prepare a mobile or Unicom SIM card and make sure the activation is available.<br>* SMS previous preparationPrepare a China Unicom or mobile SIM card, and foreign developers can choose the corresponding user SIM card according to the frequency band. The frequency band supported by OrangePi 2G-IOT is as follows:<br><br>After the SIM card is ready, install it in the OrangePi 2G-IOT card slot, noting that the OrangePi 2G-IOT SIM card slot supports the Nano-type card.<br><br><div>[[File:Orange-pi-2g-iot-img23.png|500px|]]</div><br>Install the SIM card, note the direction of insertion, the SIM card missing angle direction on the outside<br><br><div>[[File:Orange-pi-2g-iot-img25.png|500px|]]</div><br>* Login LinuxAfter the card is inserted, the Linux system is activated. Users can connect to the system in a variety of ways, including serial port mode connection, ssh mode connection, etc.Refer to the official OrangePi 2G-IOT user manual for specific connection methods.If you connect by serial port, set the port rate to 921600.<br><br><div>[[File:Orange-pi-2g-iot-img26.png|500px|]]</div><br>* Use open-source tools to dial up onlineOrangePi 2G-IOT currently supports ppp Internet access, which is based on two open source tools, ppp and wvdial.Developers can first install these two open-source tools on OrangePi 2G-IOT, using the following command:<br>sudo apt-get install ppp wvdial* Configure the wvdialAfter installation, configure the wvdial tool and modify the / etc/wvdial.conf file as follows<div style="background:#fbfaf8;padding:20px;">[Dialer defaults]<br>ISDN = 0<br>Modem Type = Analog Modem<br><nowiki>Phone = *99***1#</nowiki><br>Stupid Mode = 1<br>Dial Command = ATDT<br>Modem = /dev/modem0<br>Baud = 460800<br>Init1 = AT+COPS=0<br>Init2 = AT+CFUN=1<br>Init3 = AT+CGATT=1<br>Init4 = AT+CGDCONT=1,"IP","OrangePi_2G-IOT","",0,0<br>Init5 = AT+CGACT=1,1<br>Username = " "<br>Password = " "<br></div>* Configure the ppp toolAfter installing the ppp, configure the ppp and modify the / etc / ppp / peers / wvdial file as follows:<div style="background:#fbfaf8;padding:20px;">noauth<br>name wvdial<br>defaultroute<br>replacedefaultroute</div>* Dial up internet accessAfter configured ppp and wvdial, use the command to dial up online, developers can use the following command:<br>wvdial Tom &<div>[[File:Orange-pi-2g-iot-img49.png|500px|]]</div><br>Use the ifconfig to view the network information<br><br><div>[[File:Orange-pi-2g-iot-img50.png|500px|]]</div><br>Test the connectivity states using the ping command<br><br><div>[[File:Orange-pi-2g-iot-img51.png|500px|]]</div><br>The open source project WiringPi is working on OrangePi 2G-IOT. This section will introduce how to utilize WiringPi on OrangePi 2G-IOT. The following is definition of 40pin.<br><br><div>[[File:Orange-pi-2g-iot-img17.png|500px|]]</div><br><div>[[File:Orange-pi-i96-img32.png|500px|]]</div><br>Usage:<br><br>1)Download WiringPi image of OrangePi 2G-IOT<br><br>env GIT_SSL_NO_VERIFY=true git clone https://github.com/OrangePiLibra/WiringPi.git<br><br>2)Compile and install WiringPi<br><br>cd WiringPi<br>sudo ./build OrangePi_2G-IOT<br>sudo ./build install<br><br>3)Utilze WiringPi <br><br> cd WiringPi/example/OrangePi<br>make OrangePi<br>./OrangePi<br><br>4)Details GPIO infromation<br><br>cd WiringPi/example/OrangePi<br>cat README.md<br><br>Reality Test<br>OrangePi 2G-IOT contains GPIOA, GPIOB, GPIOC and GPIOD. Each of group has 32 gpio. The type of GPIO is "Input", "Output" and "specify function" such as "I2C", "I2S" and so on. On board, OrangePi 2G-IOT exports 40 pins as different function. User can utilize these, GPIO on different application scenarios. For example, User can configure the type of GPIO as "Input", and get current voltage from program. Another hand, User can configure GPIO as specify function, such as "Uart", "I2C" and "SPI".<br><br><div>[[File:Orange-pi-2g-iot-img54.png|500px|]]</div><br>Please note that: On OrangePi 2G-IOT, GPIOA, GPIOB and GPIOD tract as general GPIO, but GPIOC as non-general GPIO. Because of some hardware design. The host of GPIOC is modem not CPU. So, If CPU wanna control GPIOC, it must send message to Modem, and Moden get message and control GPIOC, it's not good news. In other words. on version 0.1, GPIOC only support "OUTPUT" mode. <br>The size of GPIOx group is 32, so we can get gpio map:<br>GPIOA: 0 - 31<br>GPIOB: 32 - 63<br>GPIOC: 64 - 95<br>GPIOD: 96 - 127<br>Each gpio have a unique ID, and the way of caculate as follow:<br>GPIO_A_x: ID = 0 + x<br>GPIO_B_x: ID = 32 + x<br>GPIO_C_x: ID = 64 + x<br>GPIO_D_x: ID = 96 + x<br><br>1)Set gpio as Input mode<br><br>As General GPIO, we only offer the number of GPIOx. then, use library of wiringPi, User can easily to control GPIO. GPIOC can not support "Input" mode.<br><br> <nowiki>#include <wiringPi.h></nowiki><br><nowiki>/*</nowiki> Defind unique ID <nowiki>*/</nowiki><br><nowiki>#define PA1 1</nowiki><br><nowiki>#define PB5 37</nowiki><br><nowiki>#define PD2 98</nowiki><br>int main(void)<br> {<br>unsigned int vol;<br><br><nowiki>/*</nowiki> Setup wiringPi <nowiki>*/</nowiki><br> wiringPiSetup();<br><br><nowiki>/*</nowiki> Set Input Mode <nowiki>*/</nowiki><br>pinMode(PA1, INPUT);<br>pinMode(PB5, INPUT);<br>pinMode(PD2, INPUT);<br><br><nowiki>/*</nowiki> Get value from GPIO <nowiki>*/</nowiki><br>vol = digitalRead(PA1);<br>vol = digitalRead(PB5);<br>vol = digitalRead(PD2);<br><br>return 0;<br>}<br><div>[[File:Orange-pi-2g-iot-img55.png|500px|]]</div><br>2)Set gpio as "OUTPUT" mode<br><br>All GPIO support "OUTPUT" mode. The demo code as follow:<br><br><nowiki>#</nowiki>include <wiringPi.h><br><nowiki>/*</nowiki> Defind unique ID <nowiki>*/</nowiki><br><nowiki>#</nowiki>define PA1 1<br><nowiki>#</nowiki>define PB5 37<br><nowiki>#</nowiki>define PC27 91<br><nowiki>#</nowiki>defien PD2 98<br>int main(void)<br>{<br><nowiki>/*</nowiki> Setup wiringPi <nowiki>*/</nowiki><br>iringPiSetup();<br><nowiki>/*</nowiki> Set GPIO Mode <nowiki>*/</nowiki><br>pinMode(PA1, OUTPUT);<br>pinMode(PB5, OUTPUT);<br>pinMode(PC27, OUTPUT);<br> pinMode(PD2, OUTPUT);<br><br>digitalWrite(PA1, HIGH);<br>digitalWrite(PB5, LOW);<br>digitalWrite(PC27, HIGH);<br>digitalWrite(PD2, LOW);<br><br>return 0;<br>}<br><div>[[File:Orange-pi-2g-iot-img56.png|500px|]]</div><br>